@@ -403,6 +403,68 @@ describe('MatSelect', () => {
403
403
. toBe ( false , 'Expected panel to stay closed.' ) ;
404
404
} ) ) ;
405
405
406
+ it ( 'should toggle the next option when pressing shift + DOWN_ARROW on a multi-select' ,
407
+ fakeAsync ( ( ) => {
408
+ fixture . destroy ( ) ;
409
+
410
+ const multiFixture = TestBed . createComponent ( MultiSelect ) ;
411
+ const event = createKeyboardEvent ( 'keydown' , DOWN_ARROW ) ;
412
+ Object . defineProperty ( event , 'shiftKey' , { get : ( ) => true } ) ;
413
+
414
+ multiFixture . detectChanges ( ) ;
415
+ select = multiFixture . debugElement . query ( By . css ( 'mat-select' ) ) . nativeElement ;
416
+
417
+ multiFixture . componentInstance . select . open ( ) ;
418
+ multiFixture . detectChanges ( ) ;
419
+ flush ( ) ;
420
+
421
+ expect ( multiFixture . componentInstance . select . value ) . toBeFalsy ( ) ;
422
+
423
+ dispatchEvent ( select , event ) ;
424
+ multiFixture . detectChanges ( ) ;
425
+
426
+ expect ( multiFixture . componentInstance . select . value ) . toEqual ( [ 'pizza-1' ] ) ;
427
+
428
+ dispatchEvent ( select , event ) ;
429
+ multiFixture . detectChanges ( ) ;
430
+
431
+ expect ( multiFixture . componentInstance . select . value ) . toEqual ( [ 'pizza-1' , 'tacos-2' ] ) ;
432
+ } ) ) ;
433
+
434
+ it ( 'should toggle the previous option when pressing shift + UP_ARROW on a multi-select' ,
435
+ fakeAsync ( ( ) => {
436
+ fixture . destroy ( ) ;
437
+
438
+ const multiFixture = TestBed . createComponent ( MultiSelect ) ;
439
+ const event = createKeyboardEvent ( 'keydown' , UP_ARROW ) ;
440
+ Object . defineProperty ( event , 'shiftKey' , { get : ( ) => true } ) ;
441
+
442
+ multiFixture . detectChanges ( ) ;
443
+ select = multiFixture . debugElement . query ( By . css ( 'mat-select' ) ) . nativeElement ;
444
+
445
+ multiFixture . componentInstance . select . open ( ) ;
446
+ multiFixture . detectChanges ( ) ;
447
+ flush ( ) ;
448
+
449
+ // Move focus down first.
450
+ for ( let i = 0 ; i < 5 ; i ++ ) {
451
+ dispatchKeyboardEvent ( select , 'keydown' , DOWN_ARROW ) ;
452
+ multiFixture . detectChanges ( ) ;
453
+ }
454
+
455
+ expect ( multiFixture . componentInstance . select . value ) . toBeFalsy ( ) ;
456
+
457
+ dispatchEvent ( select , event ) ;
458
+ multiFixture . detectChanges ( ) ;
459
+
460
+ expect ( multiFixture . componentInstance . select . value ) . toEqual ( [ 'chips-4' ] ) ;
461
+
462
+ dispatchEvent ( select , event ) ;
463
+ multiFixture . detectChanges ( ) ;
464
+
465
+ expect ( multiFixture . componentInstance . select . value ) . toEqual ( [ 'sandwich-3' , 'chips-4' ] ) ;
466
+ } ) ) ;
467
+
406
468
it ( 'should prevent the default action when pressing space' , fakeAsync ( ( ) => {
407
469
const event = dispatchKeyboardEvent ( select , 'keydown' , SPACE ) ;
408
470
expect ( event . defaultPrevented ) . toBe ( true ) ;
0 commit comments