Revert "refactor(router): remove deprecated initialNavigation
options (#18781)"
This reverts commit d76761bf01
.
This commit is contained in:
@ -90,6 +90,48 @@ describe('bootstrap', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should NOT wait for resolvers to complete when initialNavigation = legacy_enabled',
|
||||
(done) => {
|
||||
@Component({selector: 'test', template: 'test'})
|
||||
class TestCmpLegacyEnabled {
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
RouterModule.forRoot(
|
||||
[{path: '**', component: TestCmpLegacyEnabled, resolve: {test: TestResolver}}],
|
||||
{useHash: true, initialNavigation: 'legacy_enabled'})
|
||||
],
|
||||
declarations: [RootCmp, TestCmpLegacyEnabled],
|
||||
bootstrap: [RootCmp],
|
||||
providers: [...testProviders, TestResolver],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
})
|
||||
class TestModule {
|
||||
constructor(router: Router) {
|
||||
log.push('TestModule');
|
||||
router.events.subscribe(e => log.push(e.constructor.name));
|
||||
}
|
||||
}
|
||||
|
||||
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
|
||||
const router = res.injector.get(Router);
|
||||
expect(router.routerState.snapshot.root.firstChild).toBeNull();
|
||||
// ResolveEnd has not been emitted yet because bootstrap returned too early
|
||||
expect(log).toEqual([
|
||||
'TestModule', 'RootCmp', 'NavigationStart', 'RoutesRecognized', 'GuardsCheckStart',
|
||||
'GuardsCheckEnd', 'ResolveStart'
|
||||
]);
|
||||
|
||||
router.events.subscribe((e) => {
|
||||
if (e instanceof NavigationEnd) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not run navigation when initialNavigation = disabled', (done) => {
|
||||
@Component({selector: 'test', template: 'test'})
|
||||
class TestCmpDiabled {
|
||||
@ -120,6 +162,37 @@ describe('bootstrap', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not run navigation when initialNavigation = legacy_disabled', (done) => {
|
||||
@Component({selector: 'test', template: 'test'})
|
||||
class TestCmpLegacyDisabled {
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
RouterModule.forRoot(
|
||||
[{path: '**', component: TestCmpLegacyDisabled, resolve: {test: TestResolver}}],
|
||||
{useHash: true, initialNavigation: 'legacy_disabled'})
|
||||
],
|
||||
declarations: [RootCmp, TestCmpLegacyDisabled],
|
||||
bootstrap: [RootCmp],
|
||||
providers: [...testProviders, TestResolver],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
})
|
||||
class TestModule {
|
||||
constructor(router: Router) {
|
||||
log.push('TestModule');
|
||||
router.events.subscribe(e => log.push(e.constructor.name));
|
||||
}
|
||||
}
|
||||
|
||||
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
|
||||
const router = res.injector.get(Router);
|
||||
expect(log).toEqual(['TestModule', 'RootCmp']);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not init router navigation listeners if a non root component is bootstrapped',
|
||||
(done) => {
|
||||
@NgModule({
|
||||
|
Reference in New Issue
Block a user