@@ -16,6 +16,7 @@ import {
1616 dispatchFakeEvent ,
1717 dispatchKeyboardEvent ,
1818 dispatchMouseEvent ,
19+ createKeyboardEvent ,
1920} from '@angular/cdk/testing' ;
2021import { Component , DebugElement , Type , ViewChild } from '@angular/core' ;
2122import { ComponentFixture , fakeAsync , flush , TestBed } from '@angular/core/testing' ;
@@ -995,7 +996,7 @@ describe('MatSlider', () => {
995996 expect ( sliderInstance . value ) . toBe ( 0 ) ;
996997 } ) ;
997998
998- it ( `should take not action for presses of keys it doesn't care about` , ( ) => {
999+ it ( `should take no action for presses of keys it doesn't care about` , ( ) => {
9991000 sliderInstance . value = 50 ;
10001001
10011002 expect ( testComponent . onChange ) . not . toHaveBeenCalled ( ) ;
@@ -1008,6 +1009,26 @@ describe('MatSlider', () => {
10081009 expect ( testComponent . onChange ) . not . toHaveBeenCalled ( ) ;
10091010 expect ( sliderInstance . value ) . toBe ( 50 ) ;
10101011 } ) ;
1012+
1013+ it ( 'should ignore events modifier keys' , ( ) => {
1014+ sliderInstance . value = 0 ;
1015+
1016+ [
1017+ UP_ARROW , DOWN_ARROW , RIGHT_ARROW ,
1018+ LEFT_ARROW , PAGE_DOWN , PAGE_UP , HOME , END
1019+ ] . forEach ( key => {
1020+ const event = createKeyboardEvent ( 'keydown' , key ) ;
1021+ Object . defineProperty ( event , 'altKey' , { get : ( ) => true } ) ;
1022+ dispatchEvent ( sliderNativeElement , event ) ;
1023+ fixture . detectChanges ( ) ;
1024+ expect ( event . defaultPrevented ) . toBe ( false ) ;
1025+ } ) ;
1026+
1027+ expect ( testComponent . onInput ) . not . toHaveBeenCalled ( ) ;
1028+ expect ( testComponent . onChange ) . not . toHaveBeenCalled ( ) ;
1029+ expect ( sliderInstance . value ) . toBe ( 0 ) ;
1030+ } ) ;
1031+
10111032 } ) ;
10121033
10131034 describe ( 'slider with direction and invert' , ( ) => {
0 commit comments