@@ -388,29 +388,28 @@ describe('MatTabGroup', () => {
388388 { label : 'Another new tab' , content : 'with newer content' }
389389 ) ;
390390
391- // Select the second-to-last tab.
392- fixture . componentInstance . selectedIndex = 3 ;
391+ // Select the second tab.
392+ fixture . componentInstance . selectedIndex = 1 ;
393393 fixture . detectChanges ( ) ;
394394
395395 const component : MatTabGroup =
396396 fixture . debugElement . query ( By . css ( 'mat-tab-group' ) ) . componentInstance ;
397397
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 ) ;
400400 fixture . detectChanges ( ) ;
401401
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 ) ;
406406 } ) ;
407407
408408 it ( 'should be able to select a new tab after creation' , ( ) => {
409409 fixture . detectChanges ( ) ;
410410 const component : MatTabGroup =
411411 fixture . debugElement . query ( By . css ( 'mat-tab-group' ) ) . componentInstance ;
412412
413- // Add a new tab at the beginning.
414413 fixture . componentInstance . tabs . push ( { label : 'Last tab' , content : 'at the end' } ) ;
415414 fixture . componentInstance . selectedIndex = 3 ;
416415
0 commit comments