File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,24 @@ describe('MatTabNavBar', () => {
4949 expect ( fixture . componentInstance . activeIndex ) . toBe ( 2 ) ;
5050 } ) ;
5151
52+ it ( 'should add the active class if active' , ( ) => {
53+ let tabLink1 = fixture . debugElement . queryAll ( By . css ( 'a' ) ) [ 0 ] ;
54+ let tabLink2 = fixture . debugElement . queryAll ( By . css ( 'a' ) ) [ 1 ] ;
55+ const tabLinkElements = fixture . debugElement . queryAll ( By . css ( 'a' ) )
56+ . map ( tabLinkDebugEl => tabLinkDebugEl . nativeElement ) ;
57+
58+ tabLink1 . nativeElement . click ( ) ;
59+ fixture . detectChanges ( ) ;
60+ expect ( tabLinkElements [ 0 ] . classList . contains ( 'mat-tab-label-active' ) ) . toBeTruthy ( ) ;
61+ expect ( tabLinkElements [ 1 ] . classList . contains ( 'mat-tab-label-active' ) ) . toBeFalsy ( ) ;
62+
63+ tabLink2 . nativeElement . click ( ) ;
64+ fixture . detectChanges ( ) ;
65+ expect ( tabLinkElements [ 0 ] . classList . contains ( 'mat-tab-label-active' ) ) . toBeFalsy ( ) ;
66+ expect ( tabLinkElements [ 1 ] . classList . contains ( 'mat-tab-label-active' ) ) . toBeTruthy ( ) ;
67+
68+ } ) ;
69+
5270 it ( 'should add the disabled class if disabled' , ( ) => {
5371 const tabLinkElements = fixture . debugElement . queryAll ( By . css ( 'a' ) )
5472 . map ( tabLinkDebugEl => tabLinkDebugEl . nativeElement ) ;
Original file line number Diff line number Diff line change @@ -184,7 +184,8 @@ export const _MatTabLinkMixinBase = mixinDisabled(MatTabLinkBase);
184184 'class' : 'mat-tab-link' ,
185185 '[attr.aria-disabled]' : 'disabled.toString()' ,
186186 '[attr.tabindex]' : 'tabIndex' ,
187- '[class.mat-tab-disabled]' : 'disabled'
187+ '[class.mat-tab-disabled]' : 'disabled' ,
188+ '[class.mat-tab-label-active]' : 'active' ,
188189 }
189190} )
190191export class MatTabLink extends _MatTabLinkMixinBase implements OnDestroy , CanDisable {
You can’t perform that action at this time.
0 commit comments