diff --git a/modules/angular2/src/alt_router/router_testing_providers.ts b/modules/angular2/src/alt_router/router_testing_providers.ts
new file mode 100644
index 0000000000..07ca248910
--- /dev/null
+++ b/modules/angular2/src/alt_router/router_testing_providers.ts
@@ -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: ``})
+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]
+ },
+];
diff --git a/modules/angular2/test/testing/testing_public_browser_spec.ts b/modules/angular2/test/testing/testing_public_browser_spec.ts
index a772bed4ad..94874244d1 100644
--- a/modules/angular2/test/testing/testing_public_browser_spec.ts
+++ b/modules/angular2/test/testing/testing_public_browser_spec.ts
@@ -15,6 +15,10 @@ import {
tick
} from 'angular2/testing';
+import {ROUTER_FAKE_PROVIDERS} from 'angular2/src/alt_router/router_testing_providers';
+import {ROUTER_DIRECTIVES, Routes, Route} from 'angular2/alt_router';
+
+
import {Injectable, bind, Directive, Component, ViewMetadata} from 'angular2/core';
import {PromiseWrapper} from 'angular2/src/facade/promise';
import {XHR} from 'angular2/src/compiler/xhr';
@@ -40,6 +44,18 @@ class ExternalTemplateComp {
class BadTemplateUrl {
}
+@Component({
+ selector: 'test-router-cmp',
+ template: `one two`,
+ directives: [ROUTER_DIRECTIVES]
+})
+@Routes([
+ new Route({path: '/One', component: BadTemplateUrl}),
+ new Route({path: '/Two', component: ExternalTemplateComp}),
+])
+class TestRouterComponent {
+}
+
// Tests for angular2/testing bundle specific to the browser environment.
// For general tests, see test/testing/testing_public_spec.ts.
export function main() {
@@ -161,4 +177,14 @@ export function main() {
10000); // Long timeout here because this test makes an actual XHR, and is slow on Edge.
});
});
+
+ describe('apps with router components', () => {
+ beforeEachProviders(() => [ROUTER_FAKE_PROVIDERS]);
+
+ it('should build without a problem',
+ async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
+ tcb.createAsync(TestRouterComponent)
+ .then((fixture) => { expect(fixture.nativeElement).toHaveText('one two'); });
+ })));
+ });
}