Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/lib/tabs/tab-nav-bar/tab-nav-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ describe('MatTabNavBar', () => {
expect(fixture.componentInstance.activeIndex).toBe(2);
});

it('should add the active class if active', () => {
let tabLink1 = fixture.debugElement.queryAll(By.css('a'))[0];
let tabLink2 = fixture.debugElement.queryAll(By.css('a'))[1];
const tabLinkElements = fixture.debugElement.queryAll(By.css('a'))
.map(tabLinkDebugEl => tabLinkDebugEl.nativeElement);

tabLink1.nativeElement.click();
fixture.detectChanges();
expect(tabLinkElements[0].classList.contains('mat-tab-label-active')).toBeTruthy();
expect(tabLinkElements[1].classList.contains('mat-tab-label-active')).toBeFalsy();

tabLink2.nativeElement.click();
fixture.detectChanges();
expect(tabLinkElements[0].classList.contains('mat-tab-label-active')).toBeFalsy();
expect(tabLinkElements[1].classList.contains('mat-tab-label-active')).toBeTruthy();

});

it('should add the disabled class if disabled', () => {
const tabLinkElements = fixture.debugElement.queryAll(By.css('a'))
.map(tabLinkDebugEl => tabLinkDebugEl.nativeElement);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/tabs/tab-nav-bar/tab-nav-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ export const _MatTabLinkMixinBase = mixinDisabled(MatTabLinkBase);
'class': 'mat-tab-link',
'[attr.aria-disabled]': 'disabled.toString()',
'[attr.tabindex]': 'tabIndex',
'[class.mat-tab-disabled]': 'disabled'
'[class.mat-tab-disabled]': 'disabled',
'[class.mat-tab-label-active]': 'active',
}
})
export class MatTabLink extends _MatTabLinkMixinBase implements OnDestroy, CanDisable {
Expand Down