@@ -77,6 +77,39 @@ describe('MdRipple', () => {
77
77
expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 0 ) ;
78
78
} ) ) ;
79
79
80
+ it ( 'should remove ripples after mouseup' , fakeAsync ( ( ) => {
81
+ dispatchMouseEvent ( rippleTarget , 'mousedown' ) ;
82
+
83
+ expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 1 ) ;
84
+
85
+ // Fakes the duration of fading-in and fading-out normal ripples.
86
+ // The fade-out duration has been added to ensure that didn't start fading out.
87
+ tick ( RIPPLE_FADE_IN_DURATION + RIPPLE_FADE_OUT_DURATION ) ;
88
+
89
+ expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 1 ) ;
90
+
91
+ dispatchMouseEvent ( rippleTarget , 'mouseup' ) ;
92
+ tick ( RIPPLE_FADE_OUT_DURATION ) ;
93
+
94
+ expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 0 ) ;
95
+ } ) ) ;
96
+
97
+ it ( 'should not hide ripples while animating.' , fakeAsync ( ( ) => {
98
+ // Calculates the duration for fading-in and fading-out the ripple.
99
+ let hideDuration = RIPPLE_FADE_IN_DURATION + RIPPLE_FADE_OUT_DURATION ;
100
+
101
+ dispatchMouseEvent ( rippleTarget , 'mousedown' ) ;
102
+ dispatchMouseEvent ( rippleTarget , 'mouseup' ) ;
103
+
104
+ expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 1 ) ;
105
+
106
+ tick ( hideDuration - 10 ) ;
107
+ expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 1 ) ;
108
+
109
+ tick ( 10 ) ;
110
+ expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 0 ) ;
111
+ } ) ) ;
112
+
80
113
it ( 'creates ripples when manually triggered' , ( ) => {
81
114
expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 0 ) ;
82
115
@@ -270,6 +303,23 @@ describe('MdRipple', () => {
270
303
expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 0 ) ;
271
304
} ) ) ;
272
305
306
+ it ( 'should remove ripples that are not done fading-in' , fakeAsync ( ( ) => {
307
+ expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 0 ) ;
308
+
309
+ rippleDirective . launch ( 0 , 0 ) ;
310
+
311
+ expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 1 ) ;
312
+
313
+ tick ( RIPPLE_FADE_IN_DURATION / 2 ) ;
314
+
315
+ rippleDirective . fadeOutAll ( ) ;
316
+
317
+ tick ( RIPPLE_FADE_OUT_DURATION ) ;
318
+
319
+ expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length )
320
+ . toBe ( 0 , 'Expected no ripples to be active after calling fadeOutAll.' ) ;
321
+ } ) ) ;
322
+
273
323
} ) ;
274
324
275
325
describe ( 'configuring behavior' , ( ) => {
0 commit comments