@@ -388,29 +388,28 @@ describe('MatTabGroup', () => {
388
388
{ label : 'Another new tab' , content : 'with newer content' }
389
389
) ;
390
390
391
- // Select the second-to-last tab.
392
- fixture . componentInstance . selectedIndex = 3 ;
391
+ // Select the second tab.
392
+ fixture . componentInstance . selectedIndex = 1 ;
393
393
fixture . detectChanges ( ) ;
394
394
395
395
const component : MatTabGroup =
396
396
fixture . debugElement . query ( By . css ( 'mat-tab-group' ) ) . componentInstance ;
397
397
398
- // Remove a tab right before the selected one.
399
- fixture . componentInstance . tabs . splice ( 2 , 1 ) ;
398
+ // Remove the first tab that is right before the selected one.
399
+ fixture . componentInstance . tabs . splice ( 0 , 1 ) ;
400
400
fixture . detectChanges ( ) ;
401
401
402
- // Since the third tab has been removed and the fourth was selected before, the selected
403
- // tab moved one position to the right. Meaning that the tab is now at index: *2* .
404
- expect ( component . selectedIndex ) . toBe ( 2 ) ;
405
- expect ( component . _tabs . toArray ( ) [ 2 ] . isActive ) . toBe ( true ) ;
402
+ // Since the first tab has been removed and the second one was selected before, the selected
403
+ // tab moved one position to the right. Meaning that the tab is now the first tab .
404
+ expect ( component . selectedIndex ) . toBe ( 0 ) ;
405
+ expect ( component . _tabs . toArray ( ) [ 0 ] . isActive ) . toBe ( true ) ;
406
406
} ) ;
407
407
408
408
it ( 'should be able to select a new tab after creation' , ( ) => {
409
409
fixture . detectChanges ( ) ;
410
410
const component : MatTabGroup =
411
411
fixture . debugElement . query ( By . css ( 'mat-tab-group' ) ) . componentInstance ;
412
412
413
- // Add a new tab at the beginning.
414
413
fixture . componentInstance . tabs . push ( { label : 'Last tab' , content : 'at the end' } ) ;
415
414
fixture . componentInstance . selectedIndex = 3 ;
416
415
0 commit comments