fix(router): lazy loading keeps refetching modules (#10707)
This commit is contained in:
@ -266,6 +266,32 @@ describe('applyRedirects', () => {
|
||||
expect((<any>config[1])._loadedConfig).toBe(loadedConfig);
|
||||
});
|
||||
});
|
||||
|
||||
it('should load the configuration only once', () => {
|
||||
const loadedConfig = new LoadedRouterConfig(
|
||||
[{path: '', component: ComponentB}], <any>'stubInjector', <any>'stubFactoryResolver');
|
||||
|
||||
let called = false;
|
||||
const loader = {
|
||||
load: (injector: any, p: any) => {
|
||||
if (called) throw new Error('Should not be called twice');
|
||||
called = true;
|
||||
return of (loadedConfig);
|
||||
}
|
||||
};
|
||||
|
||||
const config = [{path: 'a', loadChildren: 'children'}];
|
||||
|
||||
applyRedirects(<any>'providedInjector', <any>loader, tree('a?k1'), config).subscribe(r => {});
|
||||
|
||||
applyRedirects(<any>'providedInjector', <any>loader, tree('a?k2'), config)
|
||||
.subscribe(
|
||||
r => {
|
||||
compareTrees(r, tree('a'));
|
||||
expect((<any>config[0])._loadedConfig).toBe(loadedConfig);
|
||||
},
|
||||
(e) => { throw 'Should not reach'; });
|
||||
});
|
||||
});
|
||||
|
||||
describe('empty paths', () => {
|
||||
|
Reference in New Issue
Block a user