mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-24 08:06:17 +08:00
fix(routes): fix providers for route unit tests
This commit is contained in:
parent
fcdd82d289
commit
ecd2cf1ca2
@ -9,12 +9,30 @@ import {
|
|||||||
TestComponentBuilder,
|
TestComponentBuilder,
|
||||||
beforeEachProviders
|
beforeEachProviders
|
||||||
} from 'angular2/testing';
|
} from 'angular2/testing';
|
||||||
import {provide} from 'angular2/core';
|
import {bind} from 'angular2/core';
|
||||||
import {<%= classifiedModuleName %>DetailComponent} from './<%= dasherizedModuleName %>-detail.component';
|
import {<%= classifiedModuleName %>DetailComponent} from './<%= dasherizedModuleName %>-detail.component';
|
||||||
|
import {Router, RouteParams} from 'angular2/router';
|
||||||
|
import {<%= classifiedModuleName %>, <%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service';
|
||||||
|
|
||||||
|
class Mock<%= classifiedModuleName %>Service {
|
||||||
|
get() { return Promise.resolve(new <%= classifiedModuleName %>(1, 'one')); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class MockRouter {
|
||||||
|
navigate() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
class MockRouteParams {
|
||||||
|
get() { return 1; }
|
||||||
|
}
|
||||||
|
|
||||||
describe('<%= classifiedModuleName %>DetailComponent', () => {
|
describe('<%= classifiedModuleName %>DetailComponent', () => {
|
||||||
|
|
||||||
beforeEachProviders(() => []);
|
beforeEachProviders(() => [
|
||||||
|
bind(<%= classifiedModuleName %>Service).toValue(new Mock<%= classifiedModuleName %>Service()),
|
||||||
|
bind(Router).toValue(new MockRouter()),
|
||||||
|
bind(RouteParams).toValue(new MockRouteParams()),
|
||||||
|
]);
|
||||||
|
|
||||||
it('should ...', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
it('should ...', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||||
return tcb.createAsync(<%= classifiedModuleName %>DetailComponent).then((fixture) => {
|
return tcb.createAsync(<%= classifiedModuleName %>DetailComponent).then((fixture) => {
|
||||||
|
@ -9,12 +9,19 @@ import {
|
|||||||
TestComponentBuilder,
|
TestComponentBuilder,
|
||||||
beforeEachProviders
|
beforeEachProviders
|
||||||
} from 'angular2/testing';
|
} from 'angular2/testing';
|
||||||
import {provide} from 'angular2/core';
|
import {bind} from 'angular2/core';
|
||||||
import {<%= classifiedModuleName %>ListComponent} from './<%= dasherizedModuleName %>-list.component';
|
import {<%= classifiedModuleName %>ListComponent} from './<%= dasherizedModuleName %>-list.component';
|
||||||
|
import {<%= classifiedModuleName %>, <%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service';
|
||||||
|
|
||||||
|
class Mock<%= classifiedModuleName %>Service {
|
||||||
|
getAll() { return Promise.resolve([new <%= classifiedModuleName %>(1, 'one')]); }
|
||||||
|
}
|
||||||
|
|
||||||
describe('<%= classifiedModuleName %>ListComponent', () => {
|
describe('<%= classifiedModuleName %>ListComponent', () => {
|
||||||
|
|
||||||
beforeEachProviders(() => []);
|
beforeEachProviders(() => [
|
||||||
|
bind(<%= classifiedModuleName %>Service).toValue(new Mock<%= classifiedModuleName %>Service()),
|
||||||
|
]);
|
||||||
|
|
||||||
it('should ...', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
it('should ...', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||||
return tcb.createAsync(<%= classifiedModuleName %>ListComponent).then((fixture) => {
|
return tcb.createAsync(<%= classifiedModuleName %>ListComponent).then((fixture) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user