@@ -4,10 +4,11 @@ import {
4
4
} from '@angular-devkit/schematics/testing' ;
5
5
import * as path from 'path' ;
6
6
import { Schema as FeatureOptions } from './schema' ;
7
- import { } from '../../schematics-core' ;
8
7
import {
9
8
getTestProjectPath ,
10
9
createWorkspace ,
10
+ defaultWorkspaceOptions ,
11
+ defaultAppOptions ,
11
12
} from '../../../schematics-core/testing' ;
12
13
13
14
describe ( 'Feature Schematic' , ( ) => {
@@ -18,7 +19,6 @@ describe('Feature Schematic', () => {
18
19
const defaultOptions : FeatureOptions = {
19
20
name : 'foo' ,
20
21
project : 'bar' ,
21
- // path: 'app',
22
22
module : '' ,
23
23
spec : true ,
24
24
group : false ,
@@ -54,6 +54,36 @@ describe('Feature Schematic', () => {
54
54
) . toBeGreaterThanOrEqual ( 0 ) ;
55
55
} ) ;
56
56
57
+ it ( 'should create all files of a feature to specified project if provided' , ( ) => {
58
+ const options = {
59
+ ...defaultOptions ,
60
+ project : 'baz' ,
61
+ } ;
62
+
63
+ const specifiedProjectPath = getTestProjectPath ( defaultWorkspaceOptions , {
64
+ ...defaultAppOptions ,
65
+ name : 'baz' ,
66
+ } ) ;
67
+
68
+ const tree = schematicRunner . runSchematic ( 'feature' , options , appTree ) ;
69
+ const files = tree . files ;
70
+ expect (
71
+ files . indexOf ( `${ specifiedProjectPath } /src/lib/foo.actions.ts` )
72
+ ) . toBeGreaterThanOrEqual ( 0 ) ;
73
+ expect (
74
+ files . indexOf ( `${ specifiedProjectPath } /src/lib/foo.reducer.ts` )
75
+ ) . toBeGreaterThanOrEqual ( 0 ) ;
76
+ expect (
77
+ files . indexOf ( `${ specifiedProjectPath } /src/lib/foo.reducer.spec.ts` )
78
+ ) . toBeGreaterThanOrEqual ( 0 ) ;
79
+ expect (
80
+ files . indexOf ( `${ specifiedProjectPath } /src/lib/foo.effects.ts` )
81
+ ) . toBeGreaterThanOrEqual ( 0 ) ;
82
+ expect (
83
+ files . indexOf ( `${ specifiedProjectPath } /src/lib/foo.effects.spec.ts` )
84
+ ) . toBeGreaterThanOrEqual ( 0 ) ;
85
+ } ) ;
86
+
57
87
it ( 'should create all files of a feature within grouped folders if group is set' , ( ) => {
58
88
const options = { ...defaultOptions , group : true } ;
59
89
@@ -85,12 +115,6 @@ describe('Feature Schematic', () => {
85
115
} ;
86
116
87
117
const tree = schematicRunner . runSchematic ( 'feature' , options , appTree ) ;
88
- const effectsFileContent = tree . readContent (
89
- `${ projectPath } /src/app/foo/effects/foo.effects.ts`
90
- ) ;
91
- const reducerFileContent = tree . readContent (
92
- `${ projectPath } /src/app/foo/reducers/foo.reducer.ts`
93
- ) ;
94
118
const moduleFileContent = tree . readContent (
95
119
`${ projectPath } /src/app/app.module.ts`
96
120
) ;
0 commit comments