@@ -104,7 +104,11 @@ describe('Effect Schematic', () => {
104
104
105
105
it ( 'should add an effect to the empty array of registered effects' , ( ) => {
106
106
const storeModule = '/src/app/store.module.ts' ;
107
- const options = { ...defaultOptions , module : 'store.module.ts' } ;
107
+ const options = {
108
+ ...defaultOptions ,
109
+ root : true ,
110
+ module : 'store.module.ts' ,
111
+ } ;
108
112
appTree = createAppModuleWithEffects (
109
113
appTree ,
110
114
storeModule ,
@@ -117,9 +121,13 @@ describe('Effect Schematic', () => {
117
121
expect ( content ) . toMatch ( / E f f e c t s M o d u l e \. f o r R o o t \( \[ F o o E f f e c t s \] \) / ) ;
118
122
} ) ;
119
123
120
- it ( 'should add an effect to the existing registered effects' , ( ) => {
124
+ it ( 'should add an effect to the existing registered root effects' , ( ) => {
121
125
const storeModule = '/src/app/store.module.ts' ;
122
- const options = { ...defaultOptions , module : 'store.module.ts' } ;
126
+ const options = {
127
+ ...defaultOptions ,
128
+ root : true ,
129
+ module : 'store.module.ts' ,
130
+ } ;
123
131
appTree = createAppModuleWithEffects (
124
132
appTree ,
125
133
storeModule ,
@@ -134,6 +142,23 @@ describe('Effect Schematic', () => {
134
142
) ;
135
143
} ) ;
136
144
145
+ it ( 'should add an effect to the existing registered feature effects' , ( ) => {
146
+ const storeModule = '/src/app/store.module.ts' ;
147
+ const options = { ...defaultOptions , module : 'store.module.ts' } ;
148
+ appTree = createAppModuleWithEffects (
149
+ appTree ,
150
+ storeModule ,
151
+ `EffectsModule.forRoot([RootEffects])\n EffectsModule.forFeature([UserEffects])`
152
+ ) ;
153
+
154
+ const tree = schematicRunner . runSchematic ( 'effect' , options , appTree ) ;
155
+ const content = getFileContent ( tree , '/src/app/store.module.ts' ) ;
156
+
157
+ expect ( content ) . toMatch (
158
+ / E f f e c t s M o d u l e \. f o r F e a t u r e \( \[ U s e r E f f e c t s , F o o E f f e c t s \] \) /
159
+ ) ;
160
+ } ) ;
161
+
137
162
it ( 'should not add an effect to registered effects defined with a variable' , ( ) => {
138
163
const storeModule = '/src/app/store.module.ts' ;
139
164
const options = { ...defaultOptions , module : 'store.module.ts' } ;
0 commit comments