@@ -763,11 +763,12 @@ describe('MatSlider', () => {
763
763
sliderNativeElement = sliderDebugElement . nativeElement ;
764
764
} ) ;
765
765
766
- it ( 'should emit change on mousedown ' , ( ) => {
766
+ it ( 'should emit change on mouseup ' , ( ) => {
767
767
expect ( testComponent . onChange ) . not . toHaveBeenCalled ( ) ;
768
768
769
769
dispatchMousedownEventSequence ( sliderNativeElement , 0.2 ) ;
770
770
fixture . detectChanges ( ) ;
771
+ dispatchSlideEndEvent ( sliderNativeElement , 0.2 ) ;
771
772
772
773
expect ( testComponent . onChange ) . toHaveBeenCalledTimes ( 1 ) ;
773
774
} ) ;
@@ -799,12 +800,15 @@ describe('MatSlider', () => {
799
800
dispatchMousedownEventSequence ( sliderNativeElement , 0.2 ) ;
800
801
fixture . detectChanges ( ) ;
801
802
802
- expect ( testComponent . onChange ) . toHaveBeenCalledTimes ( 1 ) ;
803
+ expect ( testComponent . onChange ) . not . toHaveBeenCalled ( ) ;
803
804
expect ( testComponent . onInput ) . toHaveBeenCalledTimes ( 1 ) ;
804
805
805
806
dispatchSlideEndEvent ( sliderNativeElement , 0.2 ) ;
806
807
fixture . detectChanges ( ) ;
807
808
809
+ expect ( testComponent . onChange ) . toHaveBeenCalledTimes ( 1 ) ;
810
+ expect ( testComponent . onInput ) . toHaveBeenCalledTimes ( 1 ) ;
811
+
808
812
testComponent . slider . value = 0 ;
809
813
fixture . detectChanges ( ) ;
810
814
@@ -813,6 +817,7 @@ describe('MatSlider', () => {
813
817
814
818
dispatchMousedownEventSequence ( sliderNativeElement , 0.2 ) ;
815
819
fixture . detectChanges ( ) ;
820
+ dispatchSlideEndEvent ( sliderNativeElement , 0.2 ) ;
816
821
817
822
expect ( testComponent . onChange ) . toHaveBeenCalledTimes ( 2 ) ;
818
823
expect ( testComponent . onInput ) . toHaveBeenCalledTimes ( 2 ) ;
@@ -857,8 +862,8 @@ describe('MatSlider', () => {
857
862
expect ( testComponent . onChange ) . not . toHaveBeenCalled ( ) ;
858
863
859
864
dispatchMousedownEventSequence ( sliderNativeElement , 0.75 ) ;
860
-
861
865
fixture . detectChanges ( ) ;
866
+ dispatchSlideEndEvent ( sliderNativeElement , 0.75 ) ;
862
867
863
868
// The `onInput` event should be emitted once due to a single click.
864
869
expect ( testComponent . onInput ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -1270,11 +1275,12 @@ describe('MatSlider', () => {
1270
1275
sliderNativeElement = sliderDebugElement . nativeElement ;
1271
1276
} ) ;
1272
1277
1273
- it ( 'should update the model on mousedown ' , ( ) => {
1278
+ it ( 'should update the model on mouseup ' , ( ) => {
1274
1279
expect ( testComponent . val ) . toBe ( 0 ) ;
1275
1280
1276
1281
dispatchMousedownEventSequence ( sliderNativeElement , 0.76 ) ;
1277
1282
fixture . detectChanges ( ) ;
1283
+ dispatchSlideEndEvent ( sliderNativeElement , 0.76 ) ;
1278
1284
1279
1285
expect ( testComponent . val ) . toBe ( 76 ) ;
1280
1286
} ) ;
@@ -1342,11 +1348,12 @@ describe('MatSlider', () => {
1342
1348
expect ( testComponent . control . value ) . toBe ( 0 ) ;
1343
1349
} ) ;
1344
1350
1345
- it ( 'should update the control on mousedown ' , ( ) => {
1351
+ it ( 'should update the control on mouseup ' , ( ) => {
1346
1352
expect ( testComponent . control . value ) . toBe ( 0 ) ;
1347
1353
1348
1354
dispatchMousedownEventSequence ( sliderNativeElement , 0.76 ) ;
1349
1355
fixture . detectChanges ( ) ;
1356
+ dispatchSlideEndEvent ( sliderNativeElement , 0.76 ) ;
1350
1357
1351
1358
expect ( testComponent . control . value ) . toBe ( 76 ) ;
1352
1359
} ) ;
@@ -1399,6 +1406,7 @@ describe('MatSlider', () => {
1399
1406
// but remain untouched.
1400
1407
dispatchMousedownEventSequence ( sliderNativeElement , 0.5 ) ;
1401
1408
fixture . detectChanges ( ) ;
1409
+ dispatchSlideEndEvent ( sliderNativeElement , 0.5 ) ;
1402
1410
1403
1411
expect ( sliderControl . valid ) . toBe ( true ) ;
1404
1412
expect ( sliderControl . pristine ) . toBe ( false ) ;
@@ -1435,6 +1443,7 @@ describe('MatSlider', () => {
1435
1443
1436
1444
dispatchMousedownEventSequence ( sliderNativeElement , 0.1 ) ;
1437
1445
fixture . detectChanges ( ) ;
1446
+ dispatchSlideEndEvent ( sliderNativeElement , 0.1 ) ;
1438
1447
1439
1448
expect ( testComponent . value ) . toBe ( 10 ) ;
1440
1449
expect ( testComponent . slider . value ) . toBe ( 10 ) ;
0 commit comments