fix(router): handle url fragments when no url segments present
This commit is contained in:
@ -1226,35 +1226,34 @@ describe('Integration', () => {
|
||||
|
||||
|
||||
it('should set the class on a parent element when the link is active',
|
||||
fakeAsync(inject(
|
||||
[Router, TestComponentBuilder, Location],
|
||||
(router: Router, tcb: TestComponentBuilder, location: Location) => {
|
||||
const fixture = createRoot(tcb, router, RootCmp);
|
||||
fakeAsync(inject(
|
||||
[Router, TestComponentBuilder, Location],
|
||||
(router: Router, tcb: TestComponentBuilder, location: Location) => {
|
||||
const fixture = createRoot(tcb, router, RootCmp);
|
||||
|
||||
router.resetConfig([{
|
||||
path: 'team/:id',
|
||||
component: TeamCmp,
|
||||
children: [{
|
||||
path: 'link',
|
||||
component: DummyLinkWithParentCmp,
|
||||
children: [
|
||||
{path: 'simple', component: SimpleCmp}, {path: '', component: BlankCmp}
|
||||
]
|
||||
}]
|
||||
}]);
|
||||
router.resetConfig([{
|
||||
path: 'team/:id',
|
||||
component: TeamCmp,
|
||||
children: [{
|
||||
path: 'link',
|
||||
component: DummyLinkWithParentCmp,
|
||||
children:
|
||||
[{path: 'simple', component: SimpleCmp}, {path: '', component: BlankCmp}]
|
||||
}]
|
||||
}]);
|
||||
|
||||
router.navigateByUrl('/team/22/link;exact=true');
|
||||
advance(fixture);
|
||||
expect(location.path()).toEqual('/team/22/link;exact=true');
|
||||
router.navigateByUrl('/team/22/link;exact=true');
|
||||
advance(fixture);
|
||||
expect(location.path()).toEqual('/team/22/link;exact=true');
|
||||
|
||||
const native = fixture.debugElement.nativeElement.querySelector('link-parent');
|
||||
expect(native.className).toEqual('active');
|
||||
const native = fixture.debugElement.nativeElement.querySelector('link-parent');
|
||||
expect(native.className).toEqual('active');
|
||||
|
||||
router.navigateByUrl('/team/22/link/simple');
|
||||
advance(fixture);
|
||||
expect(location.path()).toEqual('/team/22/link/simple');
|
||||
expect(native.className).toEqual('');
|
||||
})));
|
||||
router.navigateByUrl('/team/22/link/simple');
|
||||
advance(fixture);
|
||||
expect(location.path()).toEqual('/team/22/link/simple');
|
||||
expect(native.className).toEqual('');
|
||||
})));
|
||||
|
||||
it('should set the class when the link is active',
|
||||
fakeAsync(inject(
|
||||
|
Reference in New Issue
Block a user