@@ -104,7 +104,11 @@ describe('Effect Schematic', () => {
104104
105105 it ( 'should add an effect to the empty array of registered effects' , ( ) => {
106106 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+ } ;
108112 appTree = createAppModuleWithEffects (
109113 appTree ,
110114 storeModule ,
@@ -117,9 +121,13 @@ describe('Effect Schematic', () => {
117121 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 \] \) / ) ;
118122 } ) ;
119123
120- it ( 'should add an effect to the existing registered effects' , ( ) => {
124+ it ( 'should add an effect to the existing registered root effects' , ( ) => {
121125 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+ } ;
123131 appTree = createAppModuleWithEffects (
124132 appTree ,
125133 storeModule ,
@@ -134,6 +142,23 @@ describe('Effect Schematic', () => {
134142 ) ;
135143 } ) ;
136144
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+
137162 it ( 'should not add an effect to registered effects defined with a variable' , ( ) => {
138163 const storeModule = '/src/app/store.module.ts' ;
139164 const options = { ...defaultOptions , module : 'store.module.ts' } ;
0 commit comments