@@ -2,8 +2,9 @@ import {TestBed, ComponentFixture, fakeAsync, tick, inject} from '@angular/core/
22import  { Component ,  ViewChild }  from  '@angular/core' ; 
33import  { MdRipple ,  MdRippleModule ,  MD_DISABLE_RIPPLES ,  RippleState }  from  './index' ; 
44import  { ViewportRuler }  from  '../overlay/position/viewport-ruler' ; 
5- import  { RIPPLE_FADE_OUT_DURATION ,  RIPPLE_FADE_IN_DURATION }  from  './ripple-renderer' ; 
5+ import  { RIPPLE_FADE_OUT_DURATION ,  RIPPLE_FADE_IN_DURATION ,   RippleConfig }  from  './ripple-renderer' ; 
66import  { dispatchMouseEvent }  from  '../testing/dispatch-events' ; 
7+ import  { MD_RIPPLES_CONFIG }  from  './ripple' ; 
78
89/** Extracts the numeric value of a pixel size string like '123px'.  */ 
910const  pxStringToFloat  =  ( s : string )  =>  { 
@@ -390,6 +391,54 @@ describe('MdRipple', () => {
390391
391392  } ) ; 
392393
394+   describe ( 'with a global config' ,  ( )  =>  { 
395+     let  rippleDirective : MdRipple ; 
396+ 
397+     function  createTestComponent ( rippleConfig : RippleConfig )  { 
398+       // Reset the previously configured testing module to be able set new providers. 
399+       // The testing module has been initialized in the root describe group for the ripples. 
400+       TestBed . resetTestingModule ( ) ; 
401+       TestBed . configureTestingModule ( { 
402+         imports : [ MdRippleModule ] , 
403+         declarations : [ BasicRippleContainer ] , 
404+         providers : [ {  provide : MD_RIPPLES_CONFIG ,  useValue : rippleConfig  } ] 
405+       } ) ; 
406+ 
407+       fixture  =  TestBed . createComponent ( BasicRippleContainer ) ; 
408+       fixture . detectChanges ( ) ; 
409+ 
410+       rippleTarget  =  fixture . nativeElement . querySelector ( '[mat-ripple]' ) ; 
411+       rippleDirective  =  fixture . componentInstance . ripple ; 
412+     } 
413+ 
414+     it ( 'should be able to overwrite the speedFactor' ,  fakeAsync ( ( )  =>  { 
415+       createTestComponent ( {  speedFactor : 0.5  } ) ; 
416+ 
417+       dispatchMouseEvent ( rippleTarget ,  'mousedown' ) ; 
418+       dispatchMouseEvent ( rippleTarget ,  'mouseup' ) ; 
419+ 
420+       expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 1 ) ; 
421+ 
422+       // Calculates the duration for fading-in and fading-out the ripple. 
423+       tick ( RIPPLE_FADE_IN_DURATION  *  2  +  RIPPLE_FADE_OUT_DURATION ) ; 
424+ 
425+       expect ( rippleTarget . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 0 ) ; 
426+     } ) ) ; 
427+ 
428+     it ( 'should be able to overwrite the color' ,  ( )  =>  { 
429+       createTestComponent ( {  color : 'red'  } ) ; 
430+ 
431+       dispatchMouseEvent ( rippleTarget ,  'mousedown' ) ; 
432+       dispatchMouseEvent ( rippleTarget ,  'mouseup' ) ; 
433+ 
434+       let  rippleElement  =  rippleTarget . querySelector ( '.mat-ripple-element' )  as  HTMLElement ; 
435+ 
436+       expect ( rippleElement ) . toBeTruthy ( ) ; 
437+       expect ( rippleElement . style . backgroundColor ) . toBe ( 'red' ) ; 
438+     } ) ; 
439+ 
440+   } ) ; 
441+ 
393442  describe ( 'configuring behavior' ,  ( )  =>  { 
394443    let  controller : RippleContainerWithInputBindings ; 
395444    let  rippleComponent : MdRipple ; 
0 commit comments