-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): add ROUTER_FAKE_PROVIDERS to angular2/alt_router/router_…
…testing_providers This change adds providers for fake router dependecies. This allows TestComponentBuilder to create components with RouterLink and RouterOutlet directives without the test writer needing to override them.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
modules/angular2/src/alt_router/router_testing_providers.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {SpyLocation} from 'angular2/src/mock/location_mock'; | ||
import {Location} from 'angular2/platform/common'; | ||
import {Router, RouterOutletMap} from './router'; | ||
import {RouterUrlSerializer, DefaultRouterUrlSerializer} from './router_url_serializer'; | ||
import {Component, ComponentResolver} from 'angular2/core'; | ||
|
||
@Component({selector: 'fake-app-root-comp', template: `<span></span>`}) | ||
class FakeAppRootCmp { | ||
} | ||
|
||
function routerFactory(componentResolver: ComponentResolver, urlSerializer: RouterUrlSerializer, | ||
routerOutletMap: RouterOutletMap, location: Location): Router { | ||
return new Router(null, FakeAppRootCmp, componentResolver, urlSerializer, routerOutletMap, | ||
location); | ||
} | ||
|
||
export const ROUTER_FAKE_PROVIDERS: any[] = /*@ts2dart_const*/ [ | ||
RouterOutletMap, | ||
/* @ts2dart_Provider */ {provide: Location, useClass: SpyLocation}, | ||
/* @ts2dart_Provider */ {provide: RouterUrlSerializer, useClass: DefaultRouterUrlSerializer}, | ||
/* @ts2dart_Provider */ { | ||
provide: Router, | ||
useFactory: routerFactory, | ||
deps: /*@ts2dart_const*/ | ||
[ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location] | ||
}, | ||
]; |
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