diff --git a/src/reducers/__tests__/objectReducer.test.js b/src/reducers/__tests__/objectReducer.test.js index 09db08f..2a60c52 100644 --- a/src/reducers/__tests__/objectReducer.test.js +++ b/src/reducers/__tests__/objectReducer.test.js @@ -27,6 +27,14 @@ describe('ObjectReducer', () => { it('reducer should return the initial state', () => { expect(reset.reducer({ foo: 1 }, undefined, { foo: 2 })).toEqual({ foo: 2 }); }); + + it('reducer should apply the payload (if an object) to the store over the default state', () => { + expect(reset.reducer({ foo: 23, bar: 4 }, { foo: 1 }, { foo: 4, bar: 5 })).toEqual({foo: 1, bar: 5}); + }); + + it('reducer should return initial state if the payload is not an object', () => { + expect(reset.reducer({ foo: 23, bar: 4 }, 'nope!', { foo: 4, bar: 5 })).toEqual({foo: 4, bar: 5}); + }); }); describe('update', () => { diff --git a/src/reducers/objectReducer.js b/src/reducers/objectReducer.js index 7c0b0ee..324341d 100644 --- a/src/reducers/objectReducer.js +++ b/src/reducers/objectReducer.js @@ -67,7 +67,8 @@ export const DEFAULT_SHAPE_BEHAVIORS: ShapeReducerBehaviorsConfig = { }, reset: { reducer(state, payload, initialState) { - return initialState; + if (!isObject(payload)) return initialState; + return { ...initialState, ...payload }; }, validate: false, },