@@ -192,6 +192,7 @@ describe('Utils', () => {
192
192
expect ( spy . mock . calls [ 0 ] [ 0 ] ) . toMatch (
193
193
/ S t o r e d o e s n o t h a v e a v a l i d r e d u c e r /
194
194
)
195
+
195
196
spy . mockClear ( )
196
197
console . error = preSpy
197
198
} )
@@ -265,13 +266,16 @@ describe('Utils', () => {
265
266
const bar = ( state = { bar : 2 } ) => state
266
267
267
268
expect ( spy . mock . calls . length ) . toBe ( 0 )
269
+
268
270
const reducer = combineReducers ( { foo, bar } )
269
271
const state = { foo : 1 , bar : 2 , qux : 3 }
272
+
270
273
reducer ( state , { } )
271
274
reducer ( state , { } )
272
275
reducer ( state , { } )
273
276
reducer ( state , { } )
274
277
expect ( spy . mock . calls . length ) . toBe ( 1 )
278
+
275
279
reducer ( { ...state , baz : 5 } , { } )
276
280
reducer ( { ...state , baz : 5 } , { } )
277
281
reducer ( { ...state , baz : 5 } , { } )
@@ -290,10 +294,14 @@ describe('Utils', () => {
290
294
it ( 'should return an updated state when additional reducers are passed to combineReducers' , function ( ) {
291
295
const originalCompositeReducer = combineReducers ( { foo } )
292
296
const store = createStore ( originalCompositeReducer )
297
+
293
298
store . dispatch ( ACTION )
299
+
294
300
const initialState = store . getState ( )
301
+
295
302
store . replaceReducer ( combineReducers ( { foo, bar } ) )
296
303
store . dispatch ( ACTION )
304
+
297
305
const nextState = store . getState ( )
298
306
expect ( nextState ) . not . toBe ( initialState )
299
307
} )
@@ -303,31 +311,43 @@ describe('Utils', () => {
303
311
304
312
const originalCompositeReducer = combineReducers ( { foo, bar } )
305
313
const store = createStore ( originalCompositeReducer )
314
+
306
315
store . dispatch ( ACTION )
316
+
307
317
const initialState = store . getState ( )
318
+
308
319
store . replaceReducer ( combineReducers ( { baz, bar } ) )
309
320
store . dispatch ( ACTION )
321
+
310
322
const nextState = store . getState ( )
311
323
expect ( nextState ) . not . toBe ( initialState )
312
324
} )
313
325
314
326
it ( 'should return the same state when reducers passed to combineReducers not changed' , function ( ) {
315
327
const originalCompositeReducer = combineReducers ( { foo, bar } )
316
328
const store = createStore ( originalCompositeReducer )
329
+
317
330
store . dispatch ( ACTION )
331
+
318
332
const initialState = store . getState ( )
333
+
319
334
store . replaceReducer ( combineReducers ( { foo, bar } ) )
320
335
store . dispatch ( ACTION )
336
+
321
337
const nextState = store . getState ( )
322
338
expect ( nextState ) . toBe ( initialState )
323
339
} )
324
340
325
341
it ( 'should return an updated state when one of more reducers passed to the combineReducers are removed' , function ( ) {
326
342
const originalCompositeReducer = combineReducers ( { foo, bar } )
327
343
const store = createStore ( originalCompositeReducer )
344
+
328
345
store . dispatch ( ACTION )
346
+
329
347
const initialState = store . getState ( )
348
+
330
349
store . replaceReducer ( combineReducers ( { bar } ) )
350
+
331
351
const nextState = store . getState ( )
332
352
expect ( nextState ) . not . toBe ( initialState )
333
353
} )
0 commit comments