Skip to content

Instantly share code, notes, and snippets.

@jasonaden
Created July 13, 2017 21:25
Show Gist options
  • Save jasonaden/b4d025a277ff1e37ceb84addebfc8696 to your computer and use it in GitHub Desktop.
Save jasonaden/b4d025a277ff1e37ceb84addebfc8696 to your computer and use it in GitHub Desktop.
Test lazy named children
it('should allow lazy loaded module in named outlet',
fakeAsync(inject([Router, NgModuleFactoryLoader], (router: Router, loader: SpyNgModuleFactoryLoader) => {
@Component({selector: 'lazy', template: 'lazy-loaded'})
class LazyComponent {}
@NgModule({
declarations: [LazyComponent],
imports: [RouterModule.forChild([{path: 'lazy', component: LazyComponent}])]
})
class LazyLoadedModule {
}
loader.stubbedModules = {lazyModule: LazyLoadedModule};
const fixture = createRoot(router, RootCmp);
router.resetConfig([{
path: 'team/:id',
component: TeamCmp,
children: [
{path: 'user/:name', component: UserCmp},
{path: 'lazy', loadChildren: 'lazyModule', outlet: 'right'}
]
}]);
router.navigateByUrl('/team/22/user/john');
advance(fixture);
expect(fixture.nativeElement).toHaveText('team 22 [ user john, right: ]');
router.navigateByUrl('/team/22/(user/john//right:lazy/lazy)');
advance(fixture);
expect(fixture.nativeElement).toHaveText('team 22 [ user john, right: lazy-loaded ]');
})));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment