File tree 2 files changed +29
-4
lines changed
addon/ng2/blueprints/route/files/src/app/__name__
2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,30 @@ import {
9
9
TestComponentBuilder ,
10
10
beforeEachProviders
11
11
} from 'angular2/testing' ;
12
- import { provide } from 'angular2/core' ;
12
+ import { bind } from 'angular2/core' ;
13
13
import { < %= classifiedModuleName % > DetailComponent } from './<%= dasherizedModuleName %>-detail.component' ;
14
+ import { Router , RouteParams } from 'angular2/router' ;
15
+ import { < %= classifiedModuleName % > , < %= classifiedModuleName % > Service } from './<%= dasherizedModuleName %>.service' ;
16
+
17
+ class Mock < %= classifiedModuleName % > Service {
18
+ get ( ) { return Promise . resolve ( new < %= classifiedModuleName % > ( 1 , 'one' ) ) ; }
19
+ }
20
+
21
+ class MockRouter {
22
+ navigate ( ) { }
23
+ }
24
+
25
+ class MockRouteParams {
26
+ get ( ) { return 1 ; }
27
+ }
14
28
15
29
describe ( '<%= classifiedModuleName %>DetailComponent' , ( ) => {
16
30
17
- beforeEachProviders ( ( ) => [ ] ) ;
31
+ beforeEachProviders ( ( ) => [
32
+ bind ( < %= classifiedModuleName % > Service ) . toValue ( new Mock < %= classifiedModuleName % > Service ( ) ) ,
33
+ bind ( Router ) . toValue ( new MockRouter ( ) ) ,
34
+ bind ( RouteParams ) . toValue ( new MockRouteParams ( ) ) ,
35
+ ] ) ;
18
36
19
37
it ( 'should ...' , injectAsync ( [ TestComponentBuilder ] , ( tcb :TestComponentBuilder ) => {
20
38
return tcb . createAsync ( < %= classifiedModuleName % > DetailComponent ) . then ( ( fixture ) => {
Original file line number Diff line number Diff line change @@ -9,12 +9,19 @@ import {
9
9
TestComponentBuilder ,
10
10
beforeEachProviders
11
11
} from 'angular2/testing' ;
12
- import { provide } from 'angular2/core' ;
12
+ import { bind } from 'angular2/core' ;
13
13
import { < %= classifiedModuleName % > ListComponent } from './<%= dasherizedModuleName %>-list.component' ;
14
+ import { < %= classifiedModuleName % > , < %= classifiedModuleName % > Service } from './<%= dasherizedModuleName %>.service' ;
15
+
16
+ class Mock < %= classifiedModuleName % > Service {
17
+ getAll ( ) { return Promise . resolve ( [ new < %= classifiedModuleName % > ( 1 , 'one' ) ] ) ; }
18
+ }
14
19
15
20
describe ( '<%= classifiedModuleName %>ListComponent' , ( ) => {
16
21
17
- beforeEachProviders ( ( ) => [ ] ) ;
22
+ beforeEachProviders ( ( ) => [
23
+ bind ( < %= classifiedModuleName % > Service ) . toValue ( new Mock < %= classifiedModuleName % > Service ( ) ) ,
24
+ ] ) ;
18
25
19
26
it ( 'should ...' , injectAsync ( [ TestComponentBuilder ] , ( tcb :TestComponentBuilder ) => {
20
27
return tcb . createAsync ( < %= classifiedModuleName % > ListComponent ) . then ( ( fixture ) => {
You can’t perform that action at this time.
0 commit comments