feat(router): add support for custom error handlers

This commit is contained in:
vsavkin
2016-08-25 07:56:30 -07:00
committed by Victor Berchet
parent 93f323cfa2
commit 2fc5c57b31
4 changed files with 53 additions and 2 deletions

View File

@ -427,6 +427,23 @@ describe('Integration', () => {
]);
})));
it('should support custom error handlers', fakeAsync(inject([Router], (router: Router) => {
router.errorHandler = (error) => 'resolvedValue';
const fixture = createRoot(router, RootCmp);
router.resetConfig([{path: 'user/:name', component: UserCmp}]);
const recordedEvents: any[] = [];
router.events.forEach(e => recordedEvents.push(e));
let e: any;
router.navigateByUrl('/invalid').then(_ => e = _);
advance(fixture);
expect(e).toEqual('resolvedValue');
expectEvents(recordedEvents, [[NavigationStart, '/invalid'], [NavigationError, '/invalid']]);
})));
it('should replace state when path is equal to current path',
fakeAsync(inject([Router, Location], (router: Router, location: Location) => {
const fixture = createRoot(router, RootCmp);