improve code coverage on devTools.js

This commit is contained in:
Lee Bannard 2015-09-24 19:18:58 +01:00
parent d157963ceb
commit eb9ecb1e65

View File

@ -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);
});
});