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', () => {
49
49
expect ( fixture . componentInstance . activeIndex ) . toBe ( 2 ) ;
50
50
} ) ;
51
51
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
+
52
70
it ( 'should add the disabled class if disabled' , ( ) => {
53
71
const tabLinkElements = fixture . debugElement . queryAll ( By . css ( 'a' ) )
54
72
. map ( tabLinkDebugEl => tabLinkDebugEl . nativeElement ) ;
Original file line number Diff line number Diff line change @@ -184,7 +184,8 @@ export const _MatTabLinkMixinBase = mixinDisabled(MatTabLinkBase);
184
184
'class' : 'mat-tab-link' ,
185
185
'[attr.aria-disabled]' : 'disabled.toString()' ,
186
186
'[attr.tabindex]' : 'tabIndex' ,
187
- '[class.mat-tab-disabled]' : 'disabled'
187
+ '[class.mat-tab-disabled]' : 'disabled' ,
188
+ '[class.mat-tab-label-active]' : 'active' ,
188
189
}
189
190
} )
190
191
export class MatTabLink extends _MatTabLinkMixinBase implements OnDestroy , CanDisable {
You can’t perform that action at this time.
0 commit comments