fix(router): routerLinkActive should only set classes after the router has successfully navigated

This commit is contained in:
vsavkin
2016-07-20 17:51:21 -07:00
parent eb6ff65af7
commit db54a84d14
10 changed files with 69 additions and 4 deletions

View File

@ -1194,6 +1194,29 @@ describe('Integration', () => {
expect(nativeButton.className).toEqual('');
})));
it('should not set the class until the first navigation succeeds',
fakeAsync(inject(
[Router, TestComponentBuilder, Location],
(router: Router, tcb: TestComponentBuilder, location: Location) => {
@Component({
template:
'<router-outlet></router-outlet><a routerLink="/" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}" >'
})
class RootCmpWithLink {
}
const f = tcb.createFakeAsync(RootCmpWithLink);
advance(f);
const link = f.debugElement.nativeElement.querySelector('a');
expect(link.className).toEqual('');
router.initialNavigation();
advance(f);
expect(link.className).toEqual('active');
})));
it('should set the class on a parent element when the link is active',
fakeAsync(inject(