fix(router): should throw when lazy loaded module doesn't define any routes (#15001)

Closes #14596

PR Close #15001
This commit is contained in:
Dzmitry Shylovich
2017-03-08 11:36:09 +03:00
committed by Miško Hevery
parent 5152abb037
commit 82923a381d
2 changed files with 32 additions and 2 deletions

View File

@ -2697,6 +2697,27 @@ describe('Integration', () => {
expect(fixture.nativeElement).toHaveText('lazy-loaded-parent [lazy-loaded-child]');
})));
it(`should throw an error when lazy loaded module does not provide any routes`,
fakeAsync(inject(
[Router, Location, NgModuleFactoryLoader],
(router: Router, location: Location, loader: SpyNgModuleFactoryLoader) => {
@NgModule({})
class LazyLoadedModule {
}
loader.stubbedModules = {expected: LazyLoadedModule};
const fixture = createRoot(router, RootCmp);
router.resetConfig([{path: 'lazy', loadChildren: 'expected'}]);
router.navigateByUrl('/lazy');
expect(() => advance(fixture))
.toThrowError(
/A lazy loaded module must define at least 1 route, but it seems like the 'LazyLoadedModule' module hasn't defined any/);
})));
it('should have 2 injector trees: module and element',
fakeAsync(inject(
[Router, Location, NgModuleFactoryLoader],