feat(router): export routerLinkActive w/ isActive property

This commit is contained in:
Jeremy Elbourn
2016-10-25 12:51:24 -07:00
committed by vsavkin
parent 6ccbfd41dd
commit c9f58cf78c
3 changed files with 60 additions and 5 deletions

View File

@ -1638,6 +1638,43 @@ describe('Integration', () => {
expect(native.className).toEqual('active');
})));
it('should expose an isActive property', fakeAsync(() => {
@Component({
template: `<a routerLink="/team" routerLinkActive #rla="routerLinkActive"></a>
<p>{{rla.isActive}}</p>
<router-outlet></router-outlet>`
})
class ComponentWithRouterLink {
}
TestBed.configureTestingModule({declarations: [ComponentWithRouterLink]});
const router: Router = TestBed.get(Router);
router.resetConfig([
{
path: 'team',
component: TeamCmp,
},
{
path: 'otherteam',
component: TeamCmp,
}
]);
const f = TestBed.createComponent(ComponentWithRouterLink);
router.navigateByUrl('/team');
advance(f);
const paragraph = f.nativeElement.querySelector('p');
expect(paragraph.textContent).toEqual('true');
router.navigateByUrl('/otherteam');
advance(f);
expect(paragraph.textContent).toEqual('false');
}));
});
describe('lazy loading', () => {
@ -2338,4 +2375,4 @@ function createRoot(router: Router, type: any): ComponentFixture<any> {
]
})
class TestModule {
}
}