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 @@ -51,6 +51,24 @@ describe('MatTabNavBar', () => {
51
51
expect ( fixture . componentInstance . activeIndex ) . toBe ( 2 ) ;
52
52
} ) ;
53
53
54
+ it ( 'should add the active class if active' , ( ) => {
55
+ let tabLink1 = fixture . debugElement . queryAll ( By . css ( 'a' ) ) [ 0 ] ;
56
+ let tabLink2 = fixture . debugElement . queryAll ( By . css ( 'a' ) ) [ 1 ] ;
57
+ const tabLinkElements = fixture . debugElement . queryAll ( By . css ( 'a' ) )
58
+ . map ( tabLinkDebugEl => tabLinkDebugEl . nativeElement ) ;
59
+
60
+ tabLink1 . nativeElement . click ( ) ;
61
+ fixture . detectChanges ( ) ;
62
+ expect ( tabLinkElements [ 0 ] . classList . contains ( 'mat-tab-label-active' ) ) . toBeTruthy ( ) ;
63
+ expect ( tabLinkElements [ 1 ] . classList . contains ( 'mat-tab-label-active' ) ) . toBeFalsy ( ) ;
64
+
65
+ tabLink2 . nativeElement . click ( ) ;
66
+ fixture . detectChanges ( ) ;
67
+ expect ( tabLinkElements [ 0 ] . classList . contains ( 'mat-tab-label-active' ) ) . toBeFalsy ( ) ;
68
+ expect ( tabLinkElements [ 1 ] . classList . contains ( 'mat-tab-label-active' ) ) . toBeTruthy ( ) ;
69
+
70
+ } ) ;
71
+
54
72
it ( 'should add the disabled class if disabled' , ( ) => {
55
73
const tabLinkElements = fixture . debugElement . queryAll ( By . css ( 'a' ) )
56
74
. map ( tabLinkDebugEl => tabLinkDebugEl . nativeElement ) ;
Original file line number Diff line number Diff line change @@ -186,7 +186,8 @@ export const _MatTabLinkMixinBase = mixinDisabled(MatTabLinkBase);
186
186
'class' : 'mat-tab-link' ,
187
187
'[attr.aria-disabled]' : 'disabled.toString()' ,
188
188
'[attr.tabindex]' : 'tabIndex' ,
189
- '[class.mat-tab-disabled]' : 'disabled'
189
+ '[class.mat-tab-disabled]' : 'disabled' ,
190
+ '[class.mat-tab-label-active]' : 'active' ,
190
191
}
191
192
} )
192
193
export class MatTabLink extends _MatTabLinkMixinBase implements OnDestroy , CanDisable {
You can’t perform that action at this time.
0 commit comments