@@ -129,6 +129,15 @@ describe('MdTabGroup', () => {
129
129
fixture . detectChanges ( ) ;
130
130
expect ( component . selectedIndex ) . toBe ( 2 ) ;
131
131
} ) ;
132
+
133
+ it ( 'should not crash when setting the selected index to NaN' , ( ) => {
134
+ let component = fixture . debugElement . componentInstance ;
135
+
136
+ expect ( ( ) => {
137
+ component . selectedIndex = NaN ;
138
+ fixture . detectChanges ( ) ;
139
+ } ) . not . toThrow ( ) ;
140
+ } ) ;
132
141
} ) ;
133
142
134
143
describe ( 'dynamic binding tabs' , ( ) => {
@@ -244,19 +253,19 @@ describe('MdTabGroup', () => {
244
253
* Checks that the `selectedIndex` has been updated; checks that the label and body have their
245
254
* respective `active` classes
246
255
*/
247
- function checkSelectedIndex ( index : number , fixture : ComponentFixture < any > ) {
256
+ function checkSelectedIndex ( expectedIndex : number , fixture : ComponentFixture < any > ) {
248
257
fixture . detectChanges ( ) ;
249
258
250
259
let tabComponent : MdTabGroup = fixture . debugElement
251
260
. query ( By . css ( 'md-tab-group' ) ) . componentInstance ;
252
- expect ( tabComponent . selectedIndex ) . toBe ( index ) ;
261
+ expect ( tabComponent . selectedIndex ) . toBe ( expectedIndex ) ;
253
262
254
263
let tabLabelElement = fixture . debugElement
255
- . query ( By . css ( `.md-tab-label:nth-of-type(${ index + 1 } )` ) ) . nativeElement ;
264
+ . query ( By . css ( `.md-tab-label:nth-of-type(${ expectedIndex + 1 } )` ) ) . nativeElement ;
256
265
expect ( tabLabelElement . classList . contains ( 'md-tab-label-active' ) ) . toBe ( true ) ;
257
266
258
267
let tabContentElement = fixture . debugElement
259
- . query ( By . css ( `md-tab-body:nth-of-type(${ index + 1 } )` ) ) . nativeElement ;
268
+ . query ( By . css ( `md-tab-body:nth-of-type(${ expectedIndex + 1 } )` ) ) . nativeElement ;
260
269
expect ( tabContentElement . classList . contains ( 'md-tab-body-active' ) ) . toBe ( true ) ;
261
270
}
262
271
0 commit comments