Add a test for 'Expected the nextReducer to be a function.' and fix ESLint

This commit is contained in:
Zalmoxisus 2016-01-30 15:52:01 +02:00
parent d756384b6c
commit a3d053880c
2 changed files with 7 additions and 1 deletions

View File

@ -337,7 +337,7 @@ export default function instrument(monitorReducer = () => null) {
return createStore => (reducer, initialState, enhancer) => { return createStore => (reducer, initialState, enhancer) => {
function liftReducer(r) { function liftReducer(r) {
if (typeof r !== 'function') { if (typeof r !== 'function') {
throw new Error('Expected the nextReducer to be a function.') throw new Error('Expected the nextReducer to be a function.');
} }
return liftReducerWith(r, initialState, monitorReducer); return liftReducerWith(r, initialState, monitorReducer);
} }

View File

@ -322,4 +322,10 @@ describe('instrument', () => {
expect(importMonitoredLiftedStore.getState()).toEqual(exportedState); expect(importMonitoredLiftedStore.getState()).toEqual(exportedState);
}); });
}); });
it('throws if reducer is not a function', () => {
expect(() =>
instrument()(createStore)()
).toThrow('Expected the nextReducer to be a function.');
});
}); });