@@ -151,6 +151,92 @@ describe('MdTabGroup', () => {
151151 } ) ) ;
152152 } ) ;
153153
154+ describe ( 'disabled tabs' , ( ) => {
155+ let fixture : ComponentFixture < DisabledTabsTestApp > ;
156+
157+ beforeEach ( async ( ( ) => {
158+ builder . createAsync ( DisabledTabsTestApp ) . then ( f => {
159+ fixture = f ;
160+ fixture . detectChanges ( ) ;
161+ } ) ;
162+ } ) ) ;
163+
164+ it ( 'should disable the second tab' , ( ) => {
165+ let labels = fixture . debugElement . queryAll ( By . css ( '.md-tab-label' ) ) ;
166+
167+ expect ( labels [ 1 ] . nativeElement . classList . contains ( 'md-tab-disabled' ) ) . toBeTruthy ( ) ;
168+ } ) ;
169+
170+ it ( 'should skip over disabled tabs when navigating by keyboard' , ( ) => {
171+ let component : MdTabGroup = fixture . debugElement . query ( By . css ( 'md-tab-group' ) )
172+ . componentInstance ;
173+
174+ component . focusIndex = 0 ;
175+ component . focusNextTab ( ) ;
176+
177+ expect ( component . focusIndex ) . toBe ( 2 ) ;
178+
179+ component . focusNextTab ( ) ;
180+ expect ( component . focusIndex ) . toBe ( 2 ) ;
181+
182+ component . focusPreviousTab ( ) ;
183+ expect ( component . focusIndex ) . toBe ( 0 ) ;
184+
185+ component . focusPreviousTab ( ) ;
186+ expect ( component . focusIndex ) . toBe ( 0 ) ;
187+ } ) ;
188+
189+ it ( 'should ignore attempts to select a disabled tab' , ( ) => {
190+ let component : MdTabGroup = fixture . debugElement . query ( By . css ( 'md-tab-group' ) )
191+ . componentInstance ;
192+
193+ component . selectedIndex = 0 ;
194+ expect ( component . selectedIndex ) . toBe ( 0 ) ;
195+
196+ component . selectedIndex = 1 ;
197+ expect ( component . selectedIndex ) . toBe ( 0 ) ;
198+ } ) ;
199+
200+ it ( 'should ignore attempts to focus a disabled tab' , ( ) => {
201+ let component : MdTabGroup = fixture . debugElement . query ( By . css ( 'md-tab-group' ) )
202+ . componentInstance ;
203+
204+ component . focusIndex = 0 ;
205+ expect ( component . focusIndex ) . toBe ( 0 ) ;
206+
207+ component . focusIndex = 1 ;
208+ expect ( component . focusIndex ) . toBe ( 0 ) ;
209+ } ) ;
210+
211+ it ( 'should ignore attempts to set invalid selectedIndex' , ( ) => {
212+ let component : MdTabGroup = fixture . debugElement . query ( By . css ( 'md-tab-group' ) )
213+ . componentInstance ;
214+
215+ component . selectedIndex = 0 ;
216+ expect ( component . selectedIndex ) . toBe ( 0 ) ;
217+
218+ component . selectedIndex = - 1 ;
219+ expect ( component . selectedIndex ) . toBe ( 0 ) ;
220+
221+ component . selectedIndex = 4 ;
222+ expect ( component . selectedIndex ) . toBe ( 0 ) ;
223+ } ) ;
224+
225+ it ( 'should ignore attempts to set invalid focusIndex' , ( ) => {
226+ let component : MdTabGroup = fixture . debugElement . query ( By . css ( 'md-tab-group' ) )
227+ . componentInstance ;
228+
229+ component . focusIndex = 0 ;
230+ expect ( component . focusIndex ) . toBe ( 0 ) ;
231+
232+ component . focusIndex = - 1 ;
233+ expect ( component . focusIndex ) . toBe ( 0 ) ;
234+
235+ component . focusIndex = 4 ;
236+ expect ( component . focusIndex ) . toBe ( 0 ) ;
237+ } ) ;
238+ } ) ;
239+
154240 describe ( 'async tabs' , ( ) => {
155241 let fixture : ComponentFixture < AsyncTabsTestApp > ;
156242
@@ -173,7 +259,7 @@ describe('MdTabGroup', () => {
173259
174260 /**
175261 * Checks that the `selectedIndex` has been updated; checks that the label and body have the
176- * `md-active` class
262+ * `md-tab- active` class
177263 */
178264 function checkSelectedIndex ( index : number , fixture : ComponentFixture < any > ) {
179265 fixture . detectChanges ( ) ;
@@ -184,11 +270,11 @@ describe('MdTabGroup', () => {
184270
185271 let tabLabelElement = fixture . debugElement
186272 . query ( By . css ( `.md-tab-label:nth-of-type(${ index + 1 } )` ) ) . nativeElement ;
187- expect ( tabLabelElement . classList . contains ( 'md-active' ) ) . toBe ( true ) ;
273+ expect ( tabLabelElement . classList . contains ( 'md-tab- active' ) ) . toBe ( true ) ;
188274
189275 let tabContentElement = fixture . debugElement
190276 . query ( By . css ( `#${ tabLabelElement . id } ` ) ) . nativeElement ;
191- expect ( tabContentElement . classList . contains ( 'md-active' ) ) . toBe ( true ) ;
277+ expect ( tabContentElement . classList . contains ( 'md-tab- active' ) ) . toBe ( true ) ;
192278 }
193279} ) ;
194280
@@ -226,6 +312,27 @@ class SimpleTabsTestApp {
226312 }
227313}
228314
315+ @Component ( {
316+ selector : 'test-app' ,
317+ template : `
318+ <md-tab-group class="tab-group">
319+ <md-tab>
320+ <template md-tab-label>Tab One</template>
321+ <template md-tab-content>Tab one content</template>
322+ </md-tab>
323+ <md-tab disabled>
324+ <template md-tab-label>Tab Two</template>
325+ <template md-tab-content>Tab two content</template>
326+ </md-tab>
327+ <md-tab>
328+ <template md-tab-label>Tab Three</template>
329+ <template md-tab-content>Tab three content</template>
330+ </md-tab>
331+ </md-tab-group>
332+ ` ,
333+ } )
334+ class DisabledTabsTestApp { }
335+
229336@Component ( {
230337 selector : 'test-app' ,
231338 template : `
0 commit comments