fix(router): fix lazy loading of aux routes (#23459)

Fixes #10981

PR Close #23459
This commit is contained in:
Jason Aden
2018-04-06 15:56:36 -07:00
committed by Miško Hevery
parent b3089b4963
commit d20877bf3f
8 changed files with 131 additions and 17 deletions

View File

@ -123,21 +123,27 @@ describe('config', () => {
}).toThrowError(/Invalid configuration of route '{path: "", redirectTo: "b"}'/);
});
it('should throw when pathPatch is invalid', () => {
it('should throw when pathMatch is invalid', () => {
expect(() => { validateConfig([{path: 'a', pathMatch: 'invalid', component: ComponentB}]); })
.toThrowError(
/Invalid configuration of route 'a': pathMatch can only be set to 'prefix' or 'full'/);
});
it('should throw when pathPatch is invalid', () => {
expect(() => { validateConfig([{path: 'a', outlet: 'aux', children: []}]); })
it('should throw when path/outlet combination is invalid', () => {
expect(() => { validateConfig([{path: 'a', outlet: 'aux'}]); })
.toThrowError(
/Invalid configuration of route 'a': a componentless route cannot have a named outlet set/);
/Invalid configuration of route 'a': a componentless route without children or loadChildren cannot have a named outlet set/);
expect(() => validateConfig([{path: 'a', outlet: '', children: []}])).not.toThrow();
expect(() => validateConfig([{path: 'a', outlet: PRIMARY_OUTLET, children: []}]))
.not.toThrow();
});
it('should not throw when path/outlet combination is valid', () => {
expect(() => { validateConfig([{path: 'a', outlet: 'aux', children: []}]); }).not.toThrow();
expect(() => {
validateConfig([{path: 'a', outlet: 'aux', loadChildren: 'child'}]);
}).not.toThrow();
});
});
});