Skip to content

Commit 2c24ecc

Browse files
authored
Cleaning up these and some other tests while I'm here
1 parent 001a197 commit 2c24ecc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/combineReducers.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ describe('Utils', () => {
192192
expect(spy.mock.calls[0][0]).toMatch(
193193
/Store does not have a valid reducer/
194194
)
195+
195196
spy.mockClear()
196197
console.error = preSpy
197198
})
@@ -265,13 +266,16 @@ describe('Utils', () => {
265266
const bar = (state = { bar: 2 }) => state
266267

267268
expect(spy.mock.calls.length).toBe(0)
269+
268270
const reducer = combineReducers({ foo, bar })
269271
const state = { foo: 1, bar: 2, qux: 3 }
272+
270273
reducer(state, {})
271274
reducer(state, {})
272275
reducer(state, {})
273276
reducer(state, {})
274277
expect(spy.mock.calls.length).toBe(1)
278+
275279
reducer({ ...state, baz: 5 }, {})
276280
reducer({ ...state, baz: 5 }, {})
277281
reducer({ ...state, baz: 5 }, {})
@@ -290,10 +294,14 @@ describe('Utils', () => {
290294
it('should return an updated state when additional reducers are passed to combineReducers', function() {
291295
const originalCompositeReducer = combineReducers({ foo })
292296
const store = createStore(originalCompositeReducer)
297+
293298
store.dispatch(ACTION)
299+
294300
const initialState = store.getState()
301+
295302
store.replaceReducer(combineReducers({ foo, bar }))
296303
store.dispatch(ACTION)
304+
297305
const nextState = store.getState()
298306
expect(nextState).not.toBe(initialState)
299307
})
@@ -303,31 +311,43 @@ describe('Utils', () => {
303311

304312
const originalCompositeReducer = combineReducers({ foo, bar })
305313
const store = createStore(originalCompositeReducer)
314+
306315
store.dispatch(ACTION)
316+
307317
const initialState = store.getState()
318+
308319
store.replaceReducer(combineReducers({ baz, bar }))
309320
store.dispatch(ACTION)
321+
310322
const nextState = store.getState()
311323
expect(nextState).not.toBe(initialState)
312324
})
313325

314326
it('should return the same state when reducers passed to combineReducers not changed', function() {
315327
const originalCompositeReducer = combineReducers({ foo, bar })
316328
const store = createStore(originalCompositeReducer)
329+
317330
store.dispatch(ACTION)
331+
318332
const initialState = store.getState()
333+
319334
store.replaceReducer(combineReducers({ foo, bar }))
320335
store.dispatch(ACTION)
336+
321337
const nextState = store.getState()
322338
expect(nextState).toBe(initialState)
323339
})
324340

325341
it('should return an updated state when one of more reducers passed to the combineReducers are removed', function() {
326342
const originalCompositeReducer = combineReducers({ foo, bar })
327343
const store = createStore(originalCompositeReducer)
344+
328345
store.dispatch(ACTION)
346+
329347
const initialState = store.getState()
348+
330349
store.replaceReducer(combineReducers({ bar }))
350+
331351
const nextState = store.getState()
332352
expect(nextState).not.toBe(initialState)
333353
})

0 commit comments

Comments
 (0)