@@ -76,10 +76,12 @@ describe('Action Schematic', () => {
76
76
} ) ;
77
77
78
78
describe ( 'action classes' , ( ) => {
79
+ const actionClassesDefaultOptions = { ...defaultOptions , creators : false } ;
80
+
79
81
it ( 'should create an enum named "Foo"' , ( ) => {
80
82
const tree = schematicRunner . runSchematic (
81
83
'action' ,
82
- defaultOptions ,
84
+ actionClassesDefaultOptions ,
83
85
appTree
84
86
) ;
85
87
const fileContent = tree . readContent (
@@ -92,7 +94,7 @@ describe('Action Schematic', () => {
92
94
it ( 'should create a class based on the provided name' , ( ) => {
93
95
const tree = schematicRunner . runSchematic (
94
96
'action' ,
95
- defaultOptions ,
97
+ actionClassesDefaultOptions ,
96
98
appTree
97
99
) ;
98
100
const fileContent = tree . readContent (
@@ -105,7 +107,7 @@ describe('Action Schematic', () => {
105
107
it ( 'should create the union type based on the provided name' , ( ) => {
106
108
const tree = schematicRunner . runSchematic (
107
109
'action' ,
108
- defaultOptions ,
110
+ actionClassesDefaultOptions ,
109
111
appTree
110
112
) ;
111
113
const fileContent = tree . readContent (
@@ -116,7 +118,7 @@ describe('Action Schematic', () => {
116
118
} ) ;
117
119
118
120
it ( 'should create spec class with right imports' , ( ) => {
119
- const options = { ...defaultOptions , spec : true } ;
121
+ const options = { ...actionClassesDefaultOptions , spec : true } ;
120
122
const tree = schematicRunner . runSchematic ( 'action' , options , appTree ) ;
121
123
const fileContent = tree . readContent (
122
124
`${ projectPath } /src/app/foo.actions.spec.ts`
@@ -127,12 +129,12 @@ describe('Action Schematic', () => {
127
129
} ) ;
128
130
129
131
describe ( 'action creators' , ( ) => {
130
- const creatorOptions = { ...defaultOptions , creators : true } ;
132
+ const creatorDefaultOptions = { ...defaultOptions } ;
131
133
132
134
it ( 'should create a const for the action creator' , ( ) => {
133
135
const tree = schematicRunner . runSchematic (
134
136
'action' ,
135
- creatorOptions ,
137
+ creatorDefaultOptions ,
136
138
appTree
137
139
) ;
138
140
const fileContent = tree . readContent (
@@ -146,7 +148,7 @@ describe('Action Schematic', () => {
146
148
it ( 'should create success/error actions when the api flag is set' , ( ) => {
147
149
const tree = schematicRunner . runSchematic (
148
150
'action' ,
149
- { ...creatorOptions , api : true } ,
151
+ { ...creatorDefaultOptions , api : true } ,
150
152
appTree
151
153
) ;
152
154
const fileContent = tree . readContent (
@@ -161,71 +163,74 @@ describe('Action Schematic', () => {
161
163
} ) ;
162
164
} ) ;
163
165
164
- it ( 'should group within an "actions" folder if group is set' , ( ) => {
165
- const tree = schematicRunner . runSchematic (
166
- 'action' ,
167
- {
168
- ...defaultOptions ,
169
- group : true ,
170
- } ,
171
- appTree
172
- ) ;
173
- expect (
174
- tree . files . indexOf ( `${ projectPath } /src/app/actions/foo.actions.ts` )
175
- ) . toBeGreaterThanOrEqual ( 0 ) ;
176
- } ) ;
166
+ describe ( 'api' , ( ) => {
167
+ it ( 'should group within an "actions" folder if group is set' , ( ) => {
168
+ const tree = schematicRunner . runSchematic (
169
+ 'action' ,
170
+ {
171
+ ...defaultOptions ,
172
+ group : true ,
173
+ } ,
174
+ appTree
175
+ ) ;
176
+ expect (
177
+ tree . files . indexOf ( `${ projectPath } /src/app/actions/foo.actions.ts` )
178
+ ) . toBeGreaterThanOrEqual ( 0 ) ;
179
+ } ) ;
177
180
178
- it ( 'should create a success class based on the provided name, given api' , ( ) => {
179
- const tree = schematicRunner . runSchematic (
180
- 'action' ,
181
- {
182
- ...defaultOptions ,
183
- api : true ,
184
- } ,
185
- appTree
186
- ) ;
187
- const fileContent = tree . readContent (
188
- `${ projectPath } /src/app/foo.actions.ts`
189
- ) ;
181
+ it ( 'should create a success class based on the provided name, given api' , ( ) => {
182
+ const tree = schematicRunner . runSchematic (
183
+ 'action' ,
184
+ {
185
+ ...defaultOptions ,
186
+ api : true ,
187
+ } ,
188
+ appTree
189
+ ) ;
190
+ const fileContent = tree . readContent (
191
+ `${ projectPath } /src/app/foo.actions.ts`
192
+ ) ;
190
193
191
- expect ( fileContent ) . toMatch (
192
- / e x p o r t c l a s s L o a d F o o s S u c c e s s i m p l e m e n t s A c t i o n /
193
- ) ;
194
- } ) ;
194
+ expect ( fileContent ) . toMatch (
195
+ / e x p o r t c o n s t l o a d F o o s S u c c e s s = c r e a t e A c t i o n \( \r ? \n ? \s * ' \[ F o o \] L o a d F o o s S u c c e s s ' \r ? \n ? \s * , /
196
+ ) ;
197
+ } ) ;
195
198
196
- it ( 'should create a failure class based on the provided name, given api' , ( ) => {
197
- const tree = schematicRunner . runSchematic (
198
- 'action' ,
199
- {
200
- ...defaultOptions ,
201
- api : true ,
202
- } ,
203
- appTree
204
- ) ;
205
- const fileContent = tree . readContent (
206
- `${ projectPath } /src/app/foo.actions.ts`
207
- ) ;
199
+ it ( 'should create a failure class based on the provided name, given api' , ( ) => {
200
+ const tree = schematicRunner . runSchematic (
201
+ 'action' ,
202
+ {
203
+ ...defaultOptions ,
204
+ api : true ,
205
+ } ,
206
+ appTree
207
+ ) ;
208
+ const fileContent = tree . readContent (
209
+ `${ projectPath } /src/app/foo.actions.ts`
210
+ ) ;
208
211
209
- expect ( fileContent ) . toMatch (
210
- / e x p o r t c l a s s L o a d F o o s F a i l u r e i m p l e m e n t s A c t i o n /
211
- ) ;
212
- } ) ;
212
+ expect ( fileContent ) . toMatch (
213
+ / e x p o r t c o n s t l o a d F o o s F a i l u r e = c r e a t e A c t i o n \( \r ? \n ? \s * ' \[ F o o \] L o a d F o o s F a i l u r e ' \r ? \n ? \s * , /
214
+ ) ;
215
+ } ) ;
213
216
214
- it ( 'should create the union type with success and failure based on the provided name, given api' , ( ) => {
215
- const tree = schematicRunner . runSchematic (
216
- 'action' ,
217
- {
218
- ...defaultOptions ,
219
- api : true ,
220
- } ,
221
- appTree
222
- ) ;
223
- const fileContent = tree . readContent (
224
- `${ projectPath } /src/app/foo.actions.ts`
225
- ) ;
217
+ it ( 'should create the union type with success and failure based on the provided name, given api and creators false' , ( ) => {
218
+ const tree = schematicRunner . runSchematic (
219
+ 'action' ,
220
+ {
221
+ ...defaultOptions ,
222
+ api : true ,
223
+ creators : false ,
224
+ } ,
225
+ appTree
226
+ ) ;
227
+ const fileContent = tree . readContent (
228
+ `${ projectPath } /src/app/foo.actions.ts`
229
+ ) ;
226
230
227
- expect ( fileContent ) . toMatch (
228
- / e x p o r t t y p e F o o A c t i o n s = L o a d F o o s \| L o a d F o o s S u c c e s s \| L o a d F o o s F a i l u r e /
229
- ) ;
231
+ expect ( fileContent ) . toMatch (
232
+ / e x p o r t t y p e F o o A c t i o n s = L o a d F o o s \| L o a d F o o s S u c c e s s \| L o a d F o o s F a i l u r e /
233
+ ) ;
234
+ } ) ;
230
235
} ) ;
231
236
} ) ;
0 commit comments