Sets up the router to be used for testing.
查看"说明"...
提供商
提供商 |
---|
ROUTER_PROVIDERS
ROUTER_PROVIDERS
|
{ provide: Location, useClass: SpyLocation }
|
{ provide: LocationStrategy, useClass: MockLocationStrategy }
|
{ provide: NgModuleFactoryLoader, useClass: SpyNgModuleFactoryLoader }
|
{ provide: Router, useFactory: setupTestingRouter, deps: [ UrlSerializer, ChildrenOutletContexts, Location, NgModuleFactoryLoader, Compiler, Injector, ROUTES, ROUTER_CONFIGURATION, [ UrlHandlingStrategy, new Optional()] ] }
{
provide: Router,
useFactory: setupTestingRouter,
deps: [
UrlSerializer, ChildrenOutletContexts, Location, NgModuleFactoryLoader, Compiler, Injector,
ROUTES, ROUTER_CONFIGURATION, [UrlHandlingStrategy, new Optional()]
]
}
|
{ provide: PreloadingStrategy, useExisting: NoPreloading }
|
provideRoutes([])
|
使用说明
Example
beforeEach(() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule.withRoutes( [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}] ) ] }); });
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule.withRoutes(
[{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]
)
]
});
});