@@ -119,6 +119,42 @@ describe(`Store Modules`, () => {
119119 } ) ;
120120 } ) ;
121121
122+ describe ( `: With initial state` , ( ) => {
123+ const initialState : RootState = { fruit : 'banana' } ;
124+ const reducerMap : ActionReducerMap < RootState > = { fruit : rootFruitReducer } ;
125+ const noopMetaReducer = ( r : Function ) => ( state : any , action : any ) => {
126+ return r ( state , action ) ;
127+ } ;
128+
129+ const testWithMetaReducers = ( metaReducers : any [ ] ) => ( ) => {
130+ beforeEach ( ( ) => {
131+ TestBed . configureTestingModule ( {
132+ imports : [
133+ StoreModule . forRoot ( reducerMap , { initialState, metaReducers } ) ,
134+ ] ,
135+ } ) ;
136+
137+ store = TestBed . get ( Store ) ;
138+ } ) ;
139+
140+ it ( 'should have initial state' , ( ) => {
141+ store . take ( 1 ) . subscribe ( ( s : any ) => {
142+ expect ( s ) . toEqual ( initialState ) ;
143+ } ) ;
144+ } ) ;
145+ } ;
146+
147+ describe (
148+ 'should add initial state with no meta-reducers' ,
149+ testWithMetaReducers ( [ ] )
150+ ) ;
151+
152+ describe (
153+ 'should add initial state with registered meta-reducers' ,
154+ testWithMetaReducers ( [ noopMetaReducer ] )
155+ ) ;
156+ } ) ;
157+
122158 describe ( `: Nested` , ( ) => {
123159 @NgModule ( {
124160 imports : [ StoreModule . forFeature ( 'a' , featureAReducer ) ] ,
0 commit comments