@@ -24,12 +24,19 @@ import {Component, DebugElement, Type, ViewChild} from '@angular/core';
24
24
import { ComponentFixture , fakeAsync , flush , TestBed , tick , inject } from '@angular/core/testing' ;
25
25
import { FormControl , FormsModule , ReactiveFormsModule } from '@angular/forms' ;
26
26
import { By } from '@angular/platform-browser' ;
27
+ import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
27
28
import { MatSlider , MatSliderModule } from './index' ;
28
29
29
30
describe ( 'MDC-based MatSlider' , ( ) => {
30
31
function createComponent < T > ( component : Type < T > ) : ComponentFixture < T > {
31
32
TestBed . configureTestingModule ( {
32
- imports : [ MatSliderModule , ReactiveFormsModule , FormsModule , BidiModule ] ,
33
+ imports : [
34
+ MatSliderModule ,
35
+ ReactiveFormsModule ,
36
+ FormsModule ,
37
+ BidiModule ,
38
+ NoopAnimationsModule ,
39
+ ] ,
33
40
declarations : [ component ] ,
34
41
} ) . compileComponents ( ) ;
35
42
@@ -215,6 +222,7 @@ describe('MDC-based MatSlider', () => {
215
222
// Flush the "requestAnimationFrame" timer that performs the initial
216
223
// rendering of the MDC slider.
217
224
flushRequestAnimationFrame ( ) ;
225
+ fixture . detectChanges ( ) ;
218
226
} ) ) ;
219
227
220
228
it ( 'should set the default values from the attributes' , ( ) => {
@@ -247,6 +255,7 @@ describe('MDC-based MatSlider', () => {
247
255
dispatchMousedownEventSequence ( sliderNativeElement , 0.68 ) ;
248
256
fixture . detectChanges ( ) ;
249
257
flushRequestAnimationFrame ( ) ;
258
+ fixture . detectChanges ( ) ;
250
259
251
260
// The closest snap is halfway on the slider.
252
261
expect ( thumbContainerEl . style . transform ) . toContain ( 'translateX(50px)' ) ;
@@ -256,6 +265,7 @@ describe('MDC-based MatSlider', () => {
256
265
dispatchSlideEventSequence ( sliderNativeElement , 0 , 0.74 ) ;
257
266
fixture . detectChanges ( ) ;
258
267
flushRequestAnimationFrame ( ) ;
268
+ fixture . detectChanges ( ) ;
259
269
260
270
// The closest snap is at the halfway point on the slider.
261
271
expect ( thumbContainerEl . style . transform ) . toContain ( 'translateX(50px)' ) ;
@@ -318,6 +328,7 @@ describe('MDC-based MatSlider', () => {
318
328
// Flush the "requestAnimationFrame" timer that performs the initial
319
329
// rendering of the MDC slider.
320
330
flushRequestAnimationFrame ( ) ;
331
+ fixture . detectChanges ( ) ;
321
332
} ) ) ;
322
333
323
334
it ( 'should set the correct step value on mousedown' , ( ) => {
@@ -342,6 +353,7 @@ describe('MDC-based MatSlider', () => {
342
353
dispatchMousedownEventSequence ( sliderNativeElement , 0.66 ) ;
343
354
fixture . detectChanges ( ) ;
344
355
flushRequestAnimationFrame ( ) ;
356
+ fixture . detectChanges ( ) ;
345
357
346
358
// The closest step is at 75% of the slider.
347
359
expect ( thumbContainerEl . style . transform ) . toContain ( 'translateX(75px)' ) ;
@@ -358,6 +370,7 @@ describe('MDC-based MatSlider', () => {
358
370
dispatchSlideEventSequence ( sliderNativeElement , 0 , 0.88 ) ;
359
371
fixture . detectChanges ( ) ;
360
372
flushRequestAnimationFrame ( ) ;
373
+ fixture . detectChanges ( ) ;
361
374
362
375
// The closest snap is at the end of the slider.
363
376
expect ( thumbContainerEl . style . transform ) . toContain ( 'translateX(100px)' ) ;
@@ -539,6 +552,7 @@ describe('MDC-based MatSlider', () => {
539
552
// Flush the "requestAnimationFrame" timer that performs the initial
540
553
// rendering of the MDC slider.
541
554
flushRequestAnimationFrame ( ) ;
555
+ fixture . detectChanges ( ) ;
542
556
} ) ) ;
543
557
544
558
it ( 'should initialize based on bound value' , ( ) => {
@@ -550,6 +564,7 @@ describe('MDC-based MatSlider', () => {
550
564
testComponent . val = 75 ;
551
565
fixture . detectChanges ( ) ;
552
566
flushRequestAnimationFrame ( ) ;
567
+ fixture . detectChanges ( ) ;
553
568
554
569
expect ( sliderInstance . value ) . toBe ( 75 ) ;
555
570
expect ( thumbContainerEl . style . transform ) . toContain ( 'translateX(75px)' ) ;
@@ -576,6 +591,7 @@ describe('MDC-based MatSlider', () => {
576
591
// Flush the "requestAnimationFrame" timer that performs the initial
577
592
// rendering of the MDC slider.
578
593
flushRequestAnimationFrame ( ) ;
594
+ fixture . detectChanges ( ) ;
579
595
} ) ) ;
580
596
581
597
it ( 'should set the value smaller than the min value' , ( ) => {
@@ -609,6 +625,7 @@ describe('MDC-based MatSlider', () => {
609
625
// Flush the "requestAnimationFrame" timer that performs the initial
610
626
// rendering of the MDC slider.
611
627
flushRequestAnimationFrame ( ) ;
628
+ fixture . detectChanges ( ) ;
612
629
} ) ) ;
613
630
614
631
it ( 'should set the value greater than the max value' , ( ) => {
@@ -758,6 +775,7 @@ describe('MDC-based MatSlider', () => {
758
775
< HTMLElement > sliderNativeElement . querySelector ( '.mdc-slider__track-marker-container' ) ;
759
776
760
777
flushRequestAnimationFrame ( ) ;
778
+ fixture . detectChanges ( ) ;
761
779
} ) ) ;
762
780
763
781
it ( 'should set the correct tick separation' , ( ) => {
@@ -955,6 +973,7 @@ describe('MDC-based MatSlider', () => {
955
973
testComponent . dir = 'rtl' ;
956
974
fixture . detectChanges ( ) ;
957
975
flushRequestAnimationFrame ( ) ;
976
+ fixture . detectChanges ( ) ;
958
977
959
978
dispatchMousedownEventSequence ( sliderNativeElement , 0.3 ) ;
960
979
fixture . detectChanges ( ) ;
@@ -966,6 +985,7 @@ describe('MDC-based MatSlider', () => {
966
985
testComponent . dir = 'rtl' ;
967
986
fixture . detectChanges ( ) ;
968
987
flushRequestAnimationFrame ( ) ;
988
+ fixture . detectChanges ( ) ;
969
989
970
990
const thumbContainerEl = < HTMLElement > sliderNativeElement
971
991
. querySelector ( '.mdc-slider__thumb-container' ) ;
@@ -975,6 +995,7 @@ describe('MDC-based MatSlider', () => {
975
995
testComponent . dir = 'ltr' ;
976
996
fixture . detectChanges ( ) ;
977
997
flushRequestAnimationFrame ( ) ;
998
+ fixture . detectChanges ( ) ;
978
999
979
1000
expect ( thumbContainerEl . style . transform ) . toContain ( 'translateX(0px)' ) ;
980
1001
} ) ) ;
0 commit comments