Skip to content

Commit eb9ecb1

Browse files
committed
improve code coverage on devTools.js
1 parent d157963 commit eb9ecb1

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

test/devTools.spec.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function counterWithBug(state = 0, action) {
1414
switch (action.type) {
1515
case 'INCREMENT': return state + 1;
1616
case 'DECREMENT': return mistake - 1; // eslint-disable-line no-undef
17+
case 'SET_UNDEFINED': return undefined;
1718
default: return state;
1819
}
1920
}
@@ -202,18 +203,13 @@ describe('devTools', () => {
202203
spy.restore();
203204
});
204205

205-
it('returns the last non-undefined state from getState', () => {
206-
let spy = spyOn(console, 'error');
207-
208-
store.dispatch({ type: 'INCREMENT' });
209-
store.dispatch({ type: 'DECREMENT' });
210-
store.dispatch({ type: 'INCREMENT' });
211-
store.dispatch({ type: 'INCREMENT' });
212-
expect(store.getState()).toBe(2);
213-
214-
store.replaceReducer(counterWithBug);
215-
expect(store.getState()).toBe(1);
206+
it('should return the last non-undefined state from getState', () => {
207+
let storeWithBug = devTools()(createStore)(counterWithBug);
208+
storeWithBug.dispatch({ type: 'INCREMENT' });
209+
storeWithBug.dispatch({ type: 'INCREMENT' });
210+
expect(storeWithBug.getState()).toBe(2);
216211

217-
spy.restore();
212+
storeWithBug.dispatch({ type: 'SET_UNDEFINED' });
213+
expect(storeWithBug.getState()).toBe(2);
218214
});
219215
});

0 commit comments

Comments
 (0)