@@ -14,6 +14,7 @@ import {
14
14
Action ,
15
15
} from '../' ;
16
16
import { StoreConfig } from '../src/store_module' ;
17
+ import { combineReducers } from '../src/utils' ;
17
18
import {
18
19
counterReducer ,
19
20
INCREMENT ,
@@ -373,11 +374,11 @@ describe('ngRx Store', () => {
373
374
} ) ;
374
375
375
376
it ( 'should dispatch an update reducers action when a feature is added' , ( ) => {
376
- reducerManager . addFeature (
377
- createFeature ( {
378
- key : 'feature1' ,
379
- } )
380
- ) ;
377
+ reducerManager . addFeature ( {
378
+ key : 'feature1' ,
379
+ reducers : { } ,
380
+ reducerFactory : < any > combineReducers ,
381
+ } ) ;
381
382
382
383
expect ( reducerManagerDispatcherSpy ) . toHaveBeenCalledWith ( {
383
384
type : UPDATE ,
@@ -387,12 +388,16 @@ describe('ngRx Store', () => {
387
388
388
389
it ( 'should dispatch an update reducers action when multiple features are added' , ( ) => {
389
390
reducerManager . addFeatures ( [
390
- createFeature ( {
391
+ {
391
392
key : 'feature1' ,
392
- } ) ,
393
- createFeature ( {
393
+ reducers : { } ,
394
+ reducerFactory : < any > combineReducers ,
395
+ } ,
396
+ {
394
397
key : 'feature2' ,
395
- } ) ,
398
+ reducers : { } ,
399
+ reducerFactory : < any > combineReducers ,
400
+ } ,
396
401
] ) ;
397
402
398
403
expect ( reducerManagerDispatcherSpy ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -546,13 +551,42 @@ describe('ngRx Store', () => {
546
551
} ) ,
547
552
] ,
548
553
} ) ;
554
+
549
555
const mockStore = TestBed . get ( Store ) ;
550
556
const action = { type : INCREMENT } ;
557
+
551
558
mockStore . dispatch ( action ) ;
552
559
553
560
expect ( metaReducerSpy1 ) . toHaveBeenCalledWith ( counterReducer ) ;
554
561
expect ( metaReducerSpy2 ) . toHaveBeenCalledWith ( counterReducer2 ) ;
555
562
} ) ;
563
+
564
+ it ( 'should initial state with value' , ( done : DoneFn ) => {
565
+ const counterInitialState = 2 ;
566
+ TestBed . configureTestingModule ( {
567
+ imports : [
568
+ StoreModule . forRoot ( { } ) ,
569
+ StoreModule . forFeature (
570
+ 'counterState' ,
571
+ { counter : counterReducer } ,
572
+ {
573
+ initialState : { counter : counterInitialState } ,
574
+ metaReducers : [ metaReducerContainer . metaReducer1 ] ,
575
+ }
576
+ ) ,
577
+ ] ,
578
+ } ) ;
579
+
580
+ const mockStore = TestBed . get ( Store ) ;
581
+
582
+ mockStore . pipe ( take ( 1 ) ) . subscribe ( {
583
+ next ( val : any ) {
584
+ expect ( val [ 'counterState' ] . counter ) . toEqual ( counterInitialState ) ;
585
+ } ,
586
+ error : done ,
587
+ complete : done ,
588
+ } ) ;
589
+ } ) ;
556
590
} ) ;
557
591
558
592
describe ( 'Feature config token' , ( ) => {
0 commit comments