@@ -293,6 +293,29 @@ describe('MatSelect', () => {
293
293
'Expected value from second option to have been set on the model.' ) ;
294
294
} ) ) ;
295
295
296
+ it ( 'should select first/last options via the HOME/END keys on a closed select' ,
297
+ fakeAsync ( ( ) => {
298
+ const formControl = fixture . componentInstance . control ;
299
+ const firstOption = fixture . componentInstance . options . first ;
300
+ const lastOption = fixture . componentInstance . options . last ;
301
+
302
+ expect ( formControl . value ) . toBeFalsy ( 'Expected no initial value.' ) ;
303
+
304
+ const endEvent = dispatchKeyboardEvent ( select , 'keydown' , END ) ;
305
+
306
+ expect ( endEvent . defaultPrevented ) . toBe ( true ) ;
307
+ expect ( lastOption . selected ) . toBe ( true , 'Expected last option to be selected.' ) ;
308
+ expect ( formControl . value ) . toBe ( lastOption . value ,
309
+ 'Expected value from last option to have been set on the model.' ) ;
310
+
311
+ const homeEvent = dispatchKeyboardEvent ( select , 'keydown' , HOME ) ;
312
+
313
+ expect ( homeEvent . defaultPrevented ) . toBe ( true ) ;
314
+ expect ( firstOption . selected ) . toBe ( true , 'Expected first option to be selected.' ) ;
315
+ expect ( formControl . value ) . toBe ( firstOption . value ,
316
+ 'Expected value from first option to have been set on the model.' ) ;
317
+ } ) ) ;
318
+
296
319
it ( 'should resume focus from selected item after selecting via click' , fakeAsync ( ( ) => {
297
320
const formControl = fixture . componentInstance . control ;
298
321
const options = fixture . componentInstance . options . toArray ( ) ;
0 commit comments