@@ -3075,6 +3075,58 @@ describe('MatSelect', () => {
3075
3075
expect ( spy ) . toHaveBeenCalledWith ( 'steak-0' ) ;
3076
3076
} ) ) ;
3077
3077
3078
+ it ( 'should set the value when options are clicked' , fakeAsync ( ( ) => {
3079
+ const fixture = TestBed . createComponent ( BasicSelectWithoutForms ) ;
3080
+ fixture . detectChanges ( ) ;
3081
+ const select = fixture . nativeElement . querySelector ( '.mat-select' ) ;
3082
+
3083
+ expect ( fixture . componentInstance . selectedFood ) . toBeFalsy ( ) ;
3084
+
3085
+ const trigger = fixture . nativeElement . querySelector ( '.mat-select-trigger' ) ;
3086
+
3087
+ trigger . click ( ) ;
3088
+ fixture . detectChanges ( ) ;
3089
+ flush ( ) ;
3090
+
3091
+ dispatchKeyboardEvent ( select , 'keydown' , DOWN_ARROW ) ;
3092
+ fixture . detectChanges ( ) ;
3093
+ dispatchKeyboardEvent ( select , 'keydown' , DOWN_ARROW ) ;
3094
+ fixture . detectChanges ( ) ;
3095
+
3096
+ dispatchKeyboardEvent ( select , 'keydown' , TAB ) ;
3097
+ fixture . detectChanges ( ) ;
3098
+ flush ( ) ;
3099
+
3100
+ expect ( fixture . componentInstance . selectedFood ) . toBe ( 'sandwich-2' ) ;
3101
+ expect ( fixture . componentInstance . select . value ) . toBe ( 'sandwich-2' ) ;
3102
+ expect ( trigger . textContent ) . toContain ( 'Sandwich' ) ;
3103
+ } ) ) ;
3104
+
3105
+ it ( 'should not change the multiple value selection when tabbing away' , fakeAsync ( ( ) => {
3106
+ const fixture = TestBed . createComponent ( BasicSelectWithoutFormsMultiple ) ;
3107
+ fixture . detectChanges ( ) ;
3108
+
3109
+ expect ( fixture . componentInstance . selectedFoods ) . toBeFalsy ( 'Expected no value on init.' ) ;
3110
+
3111
+ const select = fixture . nativeElement . querySelector ( '.mat-select' ) ;
3112
+ const trigger = fixture . nativeElement . querySelector ( '.mat-select-trigger' ) ;
3113
+ trigger . click ( ) ;
3114
+ fixture . detectChanges ( ) ;
3115
+
3116
+ dispatchKeyboardEvent ( select , 'keydown' , DOWN_ARROW ) ;
3117
+ fixture . detectChanges ( ) ;
3118
+ dispatchKeyboardEvent ( select , 'keydown' , DOWN_ARROW ) ;
3119
+ fixture . detectChanges ( ) ;
3120
+
3121
+ dispatchKeyboardEvent ( select , 'keydown' , TAB ) ;
3122
+ fixture . detectChanges ( ) ;
3123
+ flush ( ) ;
3124
+
3125
+ expect ( fixture . componentInstance . selectedFoods )
3126
+ . toBeFalsy ( 'Expected no value after tabbing away.' ) ;
3127
+ } ) ) ;
3128
+
3129
+
3078
3130
} ) ;
3079
3131
3080
3132
describe ( 'with option centering disabled' , ( ) => {
0 commit comments