Created
July 13, 2017 21:25
-
-
Save jasonaden/b4d025a277ff1e37ceb84addebfc8696 to your computer and use it in GitHub Desktop.
Test lazy named children
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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