mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-02-07 23:20:46 +03:00
more tests
This commit is contained in:
parent
9c5b80edb4
commit
4e50f10802
|
@ -19,6 +19,15 @@ function counterWithBug(state = 0, action) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function counterWithAnotherBug(state = 0, action) {
|
||||||
|
switch (action.type) {
|
||||||
|
case 'INCREMENT': return mistake + 1; // eslint-disable-line no-undef
|
||||||
|
case 'DECREMENT': return state - 1;
|
||||||
|
case 'SET_UNDEFINED': return undefined;
|
||||||
|
default: return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function doubleCounter(state = 0, action) {
|
function doubleCounter(state = 0, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'INCREMENT': return state + 2;
|
case 'INCREMENT': return state + 2;
|
||||||
|
@ -334,6 +343,45 @@ describe('instrument', () => {
|
||||||
configuredStore.dispatch({ type: 'INCREMENT' });
|
configuredStore.dispatch({ type: 'INCREMENT' });
|
||||||
expect(configuredLiftedStore.getState().skippedActionIds).toExclude(1);
|
expect(configuredLiftedStore.getState().skippedActionIds).toExclude(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not auto-commit errors', () => {
|
||||||
|
let spy = spyOn(console, 'error');
|
||||||
|
|
||||||
|
let storeWithBug = createStore(counterWithBug, instrument(undefined, { maxAge: 3 }));
|
||||||
|
let liftedStoreWithBug = storeWithBug.liftedStore;
|
||||||
|
storeWithBug.dispatch({ type: 'DECREMENT' });
|
||||||
|
storeWithBug.dispatch({ type: 'INCREMENT' });
|
||||||
|
expect(liftedStoreWithBug.getState().stagedActionIds.length).toBe(3);
|
||||||
|
|
||||||
|
storeWithBug.dispatch({ type: 'INCREMENT' });
|
||||||
|
expect(liftedStoreWithBug.getState().stagedActionIds.length).toBe(4);
|
||||||
|
|
||||||
|
spy.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should auto-commit after hot reload', () => {
|
||||||
|
let spy = spyOn(console, 'error');
|
||||||
|
|
||||||
|
let storeWithBug = createStore(counterWithBug, instrument(undefined, { maxAge: 3 }));
|
||||||
|
let liftedStoreWithBug = storeWithBug.liftedStore;
|
||||||
|
storeWithBug.dispatch({ type: 'DECREMENT' });
|
||||||
|
storeWithBug.dispatch({ type: 'DECREMENT' });
|
||||||
|
storeWithBug.dispatch({ type: 'INCREMENT' });
|
||||||
|
storeWithBug.dispatch({ type: 'DECREMENT' });
|
||||||
|
storeWithBug.dispatch({ type: 'DECREMENT' });
|
||||||
|
storeWithBug.dispatch({ type: 'DECREMENT' });
|
||||||
|
expect(liftedStoreWithBug.getState().stagedActionIds.length).toBe(7);
|
||||||
|
|
||||||
|
// should auto-commit only 2 non-error actions
|
||||||
|
storeWithBug.replaceReducer(counterWithAnotherBug);
|
||||||
|
expect(liftedStoreWithBug.getState().stagedActionIds.length).toBe(5);
|
||||||
|
|
||||||
|
// should auto-commit down to 3 actions
|
||||||
|
storeWithBug.replaceReducer(counter);
|
||||||
|
expect(liftedStoreWithBug.getState().stagedActionIds.length).toBe(3);
|
||||||
|
|
||||||
|
spy.restore();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Import State', () => {
|
describe('Import State', () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user