@@ -126,4 +126,70 @@ describe('Feature Schematic', () => {
126
126
/ i m p o r t \* a s f r o m F o o f r o m ' \. \/ f o o \/ r e d u c e r s \/ f o o .r e d u c e r ' ; /
127
127
) ;
128
128
} ) ;
129
+
130
+ it ( 'should have all three api actions in actions type union if api flag enabled' , ( ) => {
131
+ const options = {
132
+ ...defaultOptions ,
133
+ api : true ,
134
+ } ;
135
+
136
+ const tree = schematicRunner . runSchematic ( 'feature' , options , appTree ) ;
137
+ const fileContent = tree . readContent (
138
+ `${ projectPath } /src/app/foo.actions.ts`
139
+ ) ;
140
+
141
+ expect ( fileContent ) . toMatch (
142
+ / 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 /
143
+ ) ;
144
+ } ) ;
145
+
146
+ it ( 'should have all api effect if api flag enabled' , ( ) => {
147
+ const options = {
148
+ ...defaultOptions ,
149
+ api : true ,
150
+ } ;
151
+
152
+ const tree = schematicRunner . runSchematic ( 'feature' , options , appTree ) ;
153
+ const fileContent = tree . readContent (
154
+ `${ projectPath } /src/app/foo.effects.ts`
155
+ ) ;
156
+
157
+ expect ( fileContent ) . toMatch (
158
+ / i m p o r t { A c t i o n s , E f f e c t , o f T y p e } f r o m ' @ n g r x \/ e f f e c t s ' ; /
159
+ ) ;
160
+ expect ( fileContent ) . toMatch (
161
+ / i m p o r t { c a t c h E r r o r , m a p , c o n c a t M a p } f r o m ' r x j s \/ o p e r a t o r s ' ; /
162
+ ) ;
163
+ expect ( fileContent ) . toMatch ( / i m p o r t { E M P T Y , o f } f r o m ' r x j s ' ; / ) ;
164
+ expect ( fileContent ) . toMatch (
165
+ / i m p o r t { L o a d F o o s F a i l u r e , L o a d F o o s S u c c e s s , F o o A c t i o n T y p e s , F o o A c t i o n s } f r o m ' \. \/ f o o .a c t i o n s ' ; /
166
+ ) ;
167
+
168
+ expect ( fileContent ) . toMatch ( / e x p o r t c l a s s F o o E f f e c t s / ) ;
169
+ expect ( fileContent ) . toMatch ( / l o a d F o o s \$ = t h i s \. a c t i o n s \$ .p i p e \( / ) ;
170
+ expect ( fileContent ) . toMatch ( / o f T y p e \( F o o A c t i o n T y p e s \. L o a d F o o s \) , / ) ;
171
+ expect ( fileContent ) . toMatch ( / c o n c a t M a p \( \( \) = > / ) ;
172
+ expect ( fileContent ) . toMatch ( / E M P T Y \. p i p e \( / ) ;
173
+ expect ( fileContent ) . toMatch (
174
+ / m a p \( d a t a = > n e w L o a d F o o s S u c c e s s \( { d a t a } \) \) , /
175
+ ) ;
176
+ expect ( fileContent ) . toMatch (
177
+ / c a t c h E r r o r \( e r r o r = > o f \( n e w L o a d F o o s F a i l u r e \( { e r r o r } \) \) \) \) /
178
+ ) ;
179
+ } ) ;
180
+
181
+ it ( 'should have all api actions in reducer if api flag enabled' , ( ) => {
182
+ const options = {
183
+ ...defaultOptions ,
184
+ api : true ,
185
+ } ;
186
+
187
+ const tree = schematicRunner . runSchematic ( 'feature' , options , appTree ) ;
188
+ const fileContent = tree . readContent (
189
+ `${ projectPath } /src/app/foo.reducer.ts`
190
+ ) ;
191
+
192
+ expect ( fileContent ) . toMatch ( / c a s e F o o A c t i o n T y p e s \. L o a d F o o s S u c c e s s / ) ;
193
+ expect ( fileContent ) . toMatch ( / c a s e F o o A c t i o n T y p e s \. L o a d F o o s F a i l u r e / ) ;
194
+ } ) ;
129
195
} ) ;
0 commit comments