fix(router): rerun resolvers when url changes

Closes #12603
This commit is contained in:
vsavkin
2016-10-28 15:17:00 -07:00
parent 091c390032
commit fe47e6b783
6 changed files with 67 additions and 9 deletions

View File

@ -41,7 +41,7 @@ describe('Integration', () => {
expect(location.path()).toEqual('/simple');
})));
describe('should execute navigations serialy', () => {
describe('should execute navigations serially', () => {
let log: any[] = [];
beforeEach(() => {
@ -693,6 +693,7 @@ describe('Integration', () => {
{provide: 'resolveFour', useValue: (a: any, b: any) => 4},
{provide: 'resolveSix', useClass: ResolveSix},
{provide: 'resolveError', useValue: (a: any, b: any) => Promise.reject('error')},
{provide: 'numberOfUrlSegments', useValue: (a: any, b: any) => a.url.length}
]
});
});
@ -787,6 +788,29 @@ describe('Integration', () => {
const cmp = fixture.debugElement.children[1].componentInstance;
expect(cmp.route.snapshot.data).toEqual({two: 2});
})));
it('should rerun resolvers when the urls segments of a wildcard route change',
fakeAsync(inject([Router, Location], (router: Router, location: Location) => {
const fixture = createRoot(router, RootCmp);
router.resetConfig([{
path: '**',
component: CollectParamsCmp,
resolve: {numberOfUrlSegments: 'numberOfUrlSegments'}
}]);
let e: any = null;
router.navigateByUrl('/one/two');
advance(fixture);
const cmp = fixture.debugElement.children[1].componentInstance;
expect(cmp.route.snapshot.data).toEqual({numberOfUrlSegments: 2});
router.navigateByUrl('/one/two/three');
advance(fixture);
expect(cmp.route.snapshot.data).toEqual({numberOfUrlSegments: 3});
})));
});
describe('router links', () => {