From eb9ecb1e6598c2033ebbe3500a4d132b23c0079c Mon Sep 17 00:00:00 2001 From: Lee Bannard Date: Thu, 24 Sep 2015 19:18:58 +0100 Subject: [PATCH] improve code coverage on devTools.js --- test/devTools.spec.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/test/devTools.spec.js b/test/devTools.spec.js index dbfe0c58..672fb8b9 100644 --- a/test/devTools.spec.js +++ b/test/devTools.spec.js @@ -14,6 +14,7 @@ function counterWithBug(state = 0, action) { switch (action.type) { case 'INCREMENT': return state + 1; case 'DECREMENT': return mistake - 1; // eslint-disable-line no-undef + case 'SET_UNDEFINED': return undefined; default: return state; } } @@ -202,18 +203,13 @@ describe('devTools', () => { spy.restore(); }); - it('returns the last non-undefined state from getState', () => { - let spy = spyOn(console, 'error'); + it('should return the last non-undefined state from getState', () => { + let storeWithBug = devTools()(createStore)(counterWithBug); + storeWithBug.dispatch({ type: 'INCREMENT' }); + storeWithBug.dispatch({ type: 'INCREMENT' }); + expect(storeWithBug.getState()).toBe(2); - store.dispatch({ type: 'INCREMENT' }); - store.dispatch({ type: 'DECREMENT' }); - store.dispatch({ type: 'INCREMENT' }); - store.dispatch({ type: 'INCREMENT' }); - expect(store.getState()).toBe(2); - - store.replaceReducer(counterWithBug); - expect(store.getState()).toBe(1); - - spy.restore(); + storeWithBug.dispatch({ type: 'SET_UNDEFINED' }); + expect(storeWithBug.getState()).toBe(2); }); });