@@ -20,7 +20,7 @@ import { mapTo, exhaustMap, tap } from 'rxjs/operators';
2020import { Observable } from 'rxjs' ;
2121
2222describe ( 'NgRx Effects Integration spec' , ( ) => {
23- it ( 'throws if forRoot() is used more than once' , ( done : any ) => {
23+ it ( 'throws if forRoot() with Effects is used more than once' , ( done : any ) => {
2424 TestBed . configureTestingModule ( {
2525 imports : [
2626 StoreModule . forRoot ( { } ) ,
@@ -45,6 +45,30 @@ describe('NgRx Effects Integration spec', () => {
4545 } ) ;
4646 } ) ;
4747
48+ it ( 'does not throw if forRoot() is used more than once with empty effects' , ( done : any ) => {
49+ TestBed . configureTestingModule ( {
50+ imports : [
51+ StoreModule . forRoot ( { } ) ,
52+ EffectsModule . forRoot ( [ ] ) ,
53+ RouterTestingModule . withRoutes ( [ ] ) ,
54+ ] ,
55+ } ) ;
56+
57+ let router : Router = TestBed . inject ( Router ) ;
58+ const loader : SpyNgModuleFactoryLoader = TestBed . inject (
59+ NgModuleFactoryLoader
60+ ) as SpyNgModuleFactoryLoader ;
61+
62+ // empty forRoot([]) 👇
63+ loader . stubbedModules = { feature : FeatModuleWithEmptyForRoot } ;
64+ router . resetConfig ( [ { path : 'feature-path' , loadChildren : 'feature' } ] ) ;
65+
66+ router . navigateByUrl ( '/feature-path' ) . then ( ( ) => {
67+ // success
68+ done ( ) ;
69+ } ) ;
70+ } ) ;
71+
4872 describe ( 'actions' , ( ) => {
4973 const createDispatchedReducer = ( dispatchedActions : string [ ] = [ ] ) => (
5074 state = { } ,
@@ -386,11 +410,19 @@ describe('NgRx Effects Integration spec', () => {
386410 }
387411 }
388412
413+ @Injectable ( )
414+ class SomeEffect { }
415+
389416 @NgModule ( {
390- imports : [ EffectsModule . forRoot ( ) ] ,
417+ imports : [ EffectsModule . forRoot ( [ SomeEffect ] ) ] ,
391418 } )
392419 class FeatModuleWithForRoot { }
393420
421+ @NgModule ( {
422+ imports : [ EffectsModule . forRoot ( [ ] ) ] ,
423+ } )
424+ class FeatModuleWithEmptyForRoot { }
425+
394426 @NgModule ( {
395427 imports : [
396428 EffectsModule . forFeature ( [ FeatEffectFromLazyLoadedModuleWithInitAction ] ) ,
0 commit comments