@@ -9,6 +9,7 @@ import {Observable} from 'rxjs/Observable';
99import { MdTab } from './tab' ;
1010import { ViewportRuler } from '../core/overlay/position/viewport-ruler' ;
1111import { FakeViewportRuler } from '../core/overlay/position/fake-viewport-ruler' ;
12+ import { dispatchFakeEvent } from '../core/testing/dispatch-events' ;
1213
1314
1415describe ( 'MdTabGroup' , ( ) => {
@@ -139,6 +140,39 @@ describe('MdTabGroup', () => {
139140 fixture . detectChanges ( ) ;
140141 } ) . not . toThrow ( ) ;
141142 } ) ;
143+
144+ it ( 'should show ripples for tab-group labels' , ( ) => {
145+ fixture . detectChanges ( ) ;
146+
147+ const testElement = fixture . nativeElement ;
148+ const tabLabel = fixture . debugElement . queryAll ( By . css ( '.mat-tab-label' ) ) [ 1 ] ;
149+
150+ expect ( testElement . querySelectorAll ( '.mat-ripple-element' ) . length )
151+ . toBe ( 0 , 'Expected no ripples to show up initially.' ) ;
152+
153+ dispatchFakeEvent ( tabLabel . nativeElement , 'mousedown' ) ;
154+ dispatchFakeEvent ( tabLabel . nativeElement , 'mouseup' ) ;
155+
156+ expect ( testElement . querySelectorAll ( '.mat-ripple-element' ) . length )
157+ . toBe ( 1 , 'Expected one ripple to show up on label mousedown.' ) ;
158+ } ) ;
159+
160+ it ( 'should allow disabling ripples for tab-group labels' , ( ) => {
161+ fixture . componentInstance . disableRipple = true ;
162+ fixture . detectChanges ( ) ;
163+
164+ const testElement = fixture . nativeElement ;
165+ const tabLabel = fixture . debugElement . queryAll ( By . css ( '.mat-tab-label' ) ) [ 1 ] ;
166+
167+ expect ( testElement . querySelectorAll ( '.mat-ripple-element' ) . length )
168+ . toBe ( 0 , 'Expected no ripples to show up initially.' ) ;
169+
170+ dispatchFakeEvent ( tabLabel . nativeElement , 'mousedown' ) ;
171+ dispatchFakeEvent ( tabLabel . nativeElement , 'mouseup' ) ;
172+
173+ expect ( testElement . querySelectorAll ( '.mat-ripple-element' ) . length )
174+ . toBe ( 0 , 'Expected no ripple to show up on label mousedown.' ) ;
175+ } ) ;
142176 } ) ;
143177
144178 describe ( 'dynamic binding tabs' , ( ) => {
@@ -315,6 +349,7 @@ describe('nested MdTabGroup with enabled animations', () => {
315349 <md-tab-group class="tab-group"
316350 [(selectedIndex)]="selectedIndex"
317351 [headerPosition]="headerPosition"
352+ [disableRipple]="disableRipple"
318353 (focusChange)="handleFocus($event)"
319354 (selectChange)="handleSelection($event)">
320355 <md-tab>
@@ -336,6 +371,7 @@ class SimpleTabsTestApp {
336371 selectedIndex : number = 1 ;
337372 focusEvent : any ;
338373 selectEvent : any ;
374+ disableRipple : boolean = false ;
339375 headerPosition : MdTabHeaderPosition = 'above' ;
340376 handleFocus ( event : any ) {
341377 this . focusEvent = event ;
0 commit comments