fix(router): routerLinkActive should not throw when not initialized (#13273)

Fixes #13270

PR Close #13273
This commit is contained in:
Dzmitry Shylovich
2016-12-07 03:22:38 +03:00
committed by Miško Hevery
parent b8b6b1d27a
commit 49c4b0fa92
3 changed files with 29 additions and 20 deletions

View File

@ -2032,6 +2032,8 @@ describe('Integration', () => {
@Component({
template: `<a routerLink="/team" routerLinkActive #rla="routerLinkActive"></a>
<p>{{rla.isActive}}</p>
<span *ngIf="rla.isActive"></span>
<span [ngClass]="{'highlight': rla.isActive}"></span>
<router-outlet></router-outlet>`
})
class ComponentWithRouterLink {
@ -2051,15 +2053,15 @@ describe('Integration', () => {
}
]);
const f = TestBed.createComponent(ComponentWithRouterLink);
const fixture = TestBed.createComponent(ComponentWithRouterLink);
router.navigateByUrl('/team');
advance(f);
expect(() => advance(fixture)).not.toThrow();
const paragraph = f.nativeElement.querySelector('p');
const paragraph = fixture.nativeElement.querySelector('p');
expect(paragraph.textContent).toEqual('true');
router.navigateByUrl('/otherteam');
advance(f);
advance(fixture);
expect(paragraph.textContent).toEqual('false');
}));