fix(router): absolute redirects should work with lazy loading
This commit is contained in:
@ -251,6 +251,21 @@ describe('applyRedirects', () => {
|
||||
(r) => { compareTrees(r, tree('/a/b')); }, (e) => { throw 'Should not reach'; });
|
||||
|
||||
});
|
||||
|
||||
it('should work with absolute redirects', () => {
|
||||
const loadedConfig = new LoadedRouterConfig(
|
||||
[{path: '', component: ComponentB}], <any>'stubInjector', <any>'stubFactoryResolver');
|
||||
|
||||
const loader = {load: (injector: any, p: any) => of (loadedConfig)};
|
||||
|
||||
const config =
|
||||
[{path: '', pathMatch: 'full', redirectTo: '/a'}, {path: 'a', loadChildren: 'children'}];
|
||||
|
||||
applyRedirects(<any>'providedInjector', <any>loader, tree(''), config).forEach(r => {
|
||||
compareTrees(r, tree('a'));
|
||||
expect((<any>config[1])._loadedConfig).toBe(loadedConfig);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('empty paths', () => {
|
||||
|
@ -13,7 +13,7 @@ import {ActivatedRoute, ActivatedRouteSnapshot, advanceActivatedRoute} from '../
|
||||
import {PRIMARY_OUTLET, Params} from '../src/shared';
|
||||
import {DefaultUrlSerializer, UrlSegment, UrlSegmentGroup, UrlTree} from '../src/url_tree';
|
||||
|
||||
fdescribe('createUrlTree', () => {
|
||||
describe('createUrlTree', () => {
|
||||
const serializer = new DefaultUrlSerializer();
|
||||
|
||||
it('should navigate to the root', () => {
|
||||
|
@ -259,19 +259,6 @@ describe('recognize', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not match when terminal', () => {
|
||||
recognize(
|
||||
RootComponent, [{
|
||||
path: '',
|
||||
pathMatch: 'full',
|
||||
component: ComponentA,
|
||||
children: [{path: 'b', component: ComponentB}]
|
||||
}],
|
||||
tree('b'), '')
|
||||
.subscribe(
|
||||
() => {}, (e) => { expect(e.message).toEqual('Cannot match any routes: \'b\''); });
|
||||
});
|
||||
|
||||
it('should work (nested case)', () => {
|
||||
checkRecognize(
|
||||
[{path: '', component: ComponentA, children: [{path: '', component: ComponentB}]}], '',
|
||||
@ -678,20 +665,6 @@ describe('recognize', () => {
|
||||
'Two segments cannot have the same outlet name: \'aux:b\' and \'aux:c\'.');
|
||||
});
|
||||
});
|
||||
|
||||
it('should error when no matching routes', () => {
|
||||
recognize(RootComponent, [{path: 'a', component: ComponentA}], tree('invalid'), 'invalid')
|
||||
.subscribe((_) => {}, (s: RouterStateSnapshot) => {
|
||||
expect(s.toString()).toContain('Cannot match any routes');
|
||||
});
|
||||
});
|
||||
|
||||
it('should error when no matching routes (too short)', () => {
|
||||
recognize(RootComponent, [{path: 'a/:id', component: ComponentA}], tree('a'), 'a')
|
||||
.subscribe((_) => {}, (s: RouterStateSnapshot) => {
|
||||
expect(s.toString()).toContain('Cannot match any routes');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user