@@ -9,6 +9,7 @@ import {Observable} from 'rxjs/Observable';
9
9
import { MdTab } from './tab' ;
10
10
import { ViewportRuler } from '../core/overlay/position/viewport-ruler' ;
11
11
import { FakeViewportRuler } from '../core/overlay/position/fake-viewport-ruler' ;
12
+ import { dispatchFakeEvent } from '../core/testing/dispatch-events' ;
12
13
13
14
14
15
describe ( 'MdTabGroup' , ( ) => {
@@ -139,6 +140,39 @@ describe('MdTabGroup', () => {
139
140
fixture . detectChanges ( ) ;
140
141
} ) . not . toThrow ( ) ;
141
142
} ) ;
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
+ } ) ;
142
176
} ) ;
143
177
144
178
describe ( 'dynamic binding tabs' , ( ) => {
@@ -315,6 +349,7 @@ describe('nested MdTabGroup with enabled animations', () => {
315
349
<md-tab-group class="tab-group"
316
350
[(selectedIndex)]="selectedIndex"
317
351
[headerPosition]="headerPosition"
352
+ [disableRipple]="disableRipple"
318
353
(focusChange)="handleFocus($event)"
319
354
(selectChange)="handleSelection($event)">
320
355
<md-tab>
@@ -336,6 +371,7 @@ class SimpleTabsTestApp {
336
371
selectedIndex : number = 1 ;
337
372
focusEvent : any ;
338
373
selectEvent : any ;
374
+ disableRipple : boolean = false ;
339
375
headerPosition : MdTabHeaderPosition = 'above' ;
340
376
handleFocus ( event : any ) {
341
377
this . focusEvent = event ;
0 commit comments