@@ -18,7 +18,8 @@ import {
18
18
dispatchKeyboardEvent ,
19
19
dispatchMouseEvent ,
20
20
createKeyboardEvent ,
21
- } from '../../cdk/testing/private' ;
21
+ createTouchEvent ,
22
+ } from '@angular/cdk/testing/private' ;
22
23
import { Component , DebugElement , Type , ViewChild } from '@angular/core' ;
23
24
import { ComponentFixture , fakeAsync , flush , TestBed } from '@angular/core/testing' ;
24
25
import { FormControl , FormsModule , ReactiveFormsModule } from '@angular/forms' ;
@@ -242,6 +243,17 @@ describe('MatSlider', () => {
242
243
it ( 'should have a focus indicator' , ( ) => {
243
244
expect ( sliderNativeElement . classList . contains ( 'mat-focus-indicator' ) ) . toBe ( true ) ;
244
245
} ) ;
246
+
247
+ it ( 'should not try to preventDefault on a non-cancelable event' , ( ) => {
248
+ const event = createTouchEvent ( 'touchstart' ) ;
249
+ const spy = spyOn ( event , 'preventDefault' ) ;
250
+ Object . defineProperty ( event , 'cancelable' , { value : false } ) ;
251
+
252
+ dispatchEvent ( sliderNativeElement , event ) ;
253
+ fixture . detectChanges ( ) ;
254
+
255
+ expect ( spy ) . not . toHaveBeenCalled ( ) ;
256
+ } ) ;
245
257
} ) ;
246
258
247
259
describe ( 'disabled slider' , ( ) => {
0 commit comments