diff --git a/src/__tests__/handleAction-test.js b/src/__tests__/handleAction-test.js index caa43051..ca156547 100644 --- a/src/__tests__/handleAction-test.js +++ b/src/__tests__/handleAction-test.js @@ -19,6 +19,13 @@ describe('handleAction()', () => { counter: 7 }); }); + it('returns default state if action is empty', () => { + const reducer = handleAction('NOTTYPE', () => null, { counter: 7 }); + expect(reducer(undefined, {})) + .to.deep.equal({ + counter: 7 + }); + }); it('accepts single function as handler', () => { const reducer = handleAction(type, (state, action) => ({ diff --git a/src/handleAction.js b/src/handleAction.js index 207f9071..800a8115 100644 --- a/src/handleAction.js +++ b/src/handleAction.js @@ -12,7 +12,7 @@ export default function handleAction(actionType, reducers, defaultState) { : [reducers.next, reducers.throw].map(reducer => (isNil(reducer) ? identity : reducer)); return (state = defaultState, action) => { - if (!includes(actionTypes, action.type.toString())) { + if (action.type == null || !includes(actionTypes, action.type.toString())) { return state; }