fix(router): add a test to make sure canDeactivate guards are called for aux routes
Closes #11345
This commit is contained in:
parent
b74185369f
commit
fc60fa790c
@ -1147,6 +1147,34 @@ describe('Integration', () => {
|
|||||||
]);
|
]);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
it('works with aux routes',
|
||||||
|
fakeAsync(inject([Router, Location], (router: Router, location: Location) => {
|
||||||
|
const fixture = createRoot(router, RootCmp);
|
||||||
|
|
||||||
|
router.resetConfig([{
|
||||||
|
path: 'two-outlets',
|
||||||
|
component: TwoOutletsCmp,
|
||||||
|
children: [
|
||||||
|
{path: 'a', component: BlankCmp}, {
|
||||||
|
path: 'b',
|
||||||
|
canDeactivate: ['RecordingDeactivate'],
|
||||||
|
component: SimpleCmp,
|
||||||
|
outlet: 'aux'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]);
|
||||||
|
|
||||||
|
router.navigateByUrl('/two-outlets/(a//aux:b)');
|
||||||
|
advance(fixture);
|
||||||
|
expect(location.path()).toEqual('/two-outlets/(a//aux:b)');
|
||||||
|
|
||||||
|
router.navigate(['two-outlets', {outlets: {aux: null}}]);
|
||||||
|
advance(fixture);
|
||||||
|
|
||||||
|
expect(log).toEqual([['Deactivate', 'b']]);
|
||||||
|
expect(location.path()).toEqual('/two-outlets/(a)');
|
||||||
|
})));
|
||||||
|
|
||||||
it('works with a nested route',
|
it('works with a nested route',
|
||||||
fakeAsync(inject([Router, Location], (router: Router, location: Location) => {
|
fakeAsync(inject([Router, Location], (router: Router, location: Location) => {
|
||||||
const fixture = createRoot(router, RootCmp);
|
const fixture = createRoot(router, RootCmp);
|
||||||
@ -2057,6 +2085,14 @@ class TeamCmp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'two-outlets-cmp',
|
||||||
|
template: `[ <router-outlet></router-outlet>, aux: <router-outlet name="aux"></router-outlet> ]`
|
||||||
|
})
|
||||||
|
class TwoOutletsCmp {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Component({selector: 'user-cmp', template: `user {{name | async}}`})
|
@Component({selector: 'user-cmp', template: `user {{name | async}}`})
|
||||||
class UserCmp {
|
class UserCmp {
|
||||||
name: Observable<string>;
|
name: Observable<string>;
|
||||||
@ -2159,6 +2195,7 @@ function createRoot(router: Router, type: any): ComponentFixture<any> {
|
|||||||
entryComponents: [
|
entryComponents: [
|
||||||
BlankCmp,
|
BlankCmp,
|
||||||
SimpleCmp,
|
SimpleCmp,
|
||||||
|
TwoOutletsCmp,
|
||||||
TeamCmp,
|
TeamCmp,
|
||||||
UserCmp,
|
UserCmp,
|
||||||
StringLinkCmp,
|
StringLinkCmp,
|
||||||
@ -2183,6 +2220,7 @@ function createRoot(router: Router, type: any): ComponentFixture<any> {
|
|||||||
exports: [
|
exports: [
|
||||||
BlankCmp,
|
BlankCmp,
|
||||||
SimpleCmp,
|
SimpleCmp,
|
||||||
|
TwoOutletsCmp,
|
||||||
TeamCmp,
|
TeamCmp,
|
||||||
UserCmp,
|
UserCmp,
|
||||||
StringLinkCmp,
|
StringLinkCmp,
|
||||||
@ -2209,6 +2247,7 @@ function createRoot(router: Router, type: any): ComponentFixture<any> {
|
|||||||
BlankCmp,
|
BlankCmp,
|
||||||
SimpleCmp,
|
SimpleCmp,
|
||||||
TeamCmp,
|
TeamCmp,
|
||||||
|
TwoOutletsCmp,
|
||||||
UserCmp,
|
UserCmp,
|
||||||
StringLinkCmp,
|
StringLinkCmp,
|
||||||
DummyLinkCmp,
|
DummyLinkCmp,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user