Skip to content

Commit

Permalink
fixup! fix(router): fix regression where navigateByUrl promise didn't…
Browse files Browse the repository at this point in the history
… resolve on CanLoad failure
  • Loading branch information
jasonaden committed Oct 15, 2018
1 parent b6db444 commit 4a6ef3e
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions packages/router/test/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2799,41 +2799,41 @@ describe('Integration', () => {
// Regression where navigateByUrl with false CanLoad no longer resolved `false` value on
// navigateByUrl promise: https://github.com/angular/angular/issues/26284
it('should resolve navigateByUrl promise after CanLoad executes',
fakeAsync(inject(
[Router, Location, NgModuleFactoryLoader],
(router: Router, location: Location, loader: SpyNgModuleFactoryLoader) => {
fakeAsync(inject(
[Router, Location, NgModuleFactoryLoader],
(router: Router, location: Location, loader: SpyNgModuleFactoryLoader) => {

@Component({selector: 'lazy', template: 'lazy-loaded'})
class LazyLoadedComponent {
}
@Component({selector: 'lazy', template: 'lazy-loaded'})
class LazyLoadedComponent {
}

@NgModule({
declarations: [LazyLoadedComponent],
imports:
[RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]
})
class LazyLoadedModule {
}
@NgModule({
declarations: [LazyLoadedComponent],
imports:
[RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]
})
class LazyLoadedModule {
}

loader.stubbedModules = {lazy: LazyLoadedModule};
const fixture = createRoot(router, RootCmp);
loader.stubbedModules = {lazy: LazyLoadedModule};
const fixture = createRoot(router, RootCmp);

router.resetConfig([
{path: 'lazy-false', canLoad: ['alwaysFalse'], loadChildren: 'lazy'},
{path: 'lazy-true', canLoad: ['alwaysTrue'], loadChildren: 'lazy'},
]);
router.resetConfig([
{path: 'lazy-false', canLoad: ['alwaysFalse'], loadChildren: 'lazy'},
{path: 'lazy-true', canLoad: ['alwaysTrue'], loadChildren: 'lazy'},
]);

let navFalseResult: any;
let navTrueResult: any;
router.navigateByUrl('/lazy-false').then(v => { navFalseResult = v; });
advance(fixture);
router.navigateByUrl('/lazy-true').then(v => { navTrueResult = v; });
advance(fixture);
let navFalseResult: any;
let navTrueResult: any;
router.navigateByUrl('/lazy-false').then(v => { navFalseResult = v; });
advance(fixture);
router.navigateByUrl('/lazy-true').then(v => { navTrueResult = v; });
advance(fixture);

expect(navFalseResult).toBe(false);
expect(navTrueResult).toBe(true);
expect(navFalseResult).toBe(false);
expect(navTrueResult).toBe(true);

})));
})));

it('should execute CanLoad only once',
fakeAsync(inject(
Expand Down

0 comments on commit 4a6ef3e

Please sign in to comment.