mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-02-07 23:20:46 +03:00
fix skipped and spec
This commit is contained in:
parent
9bafa7a0d7
commit
5c74b7f986
|
@ -238,7 +238,7 @@ function liftReducerWith(reducer, initialCommittedState, monitorReducer, options
|
||||||
if (options.maxAge && stagedActionIds.length === options.maxAge) {
|
if (options.maxAge && stagedActionIds.length === options.maxAge) {
|
||||||
// If maxAge has been reached, remove oldest action.
|
// If maxAge has been reached, remove oldest action.
|
||||||
delete actionsById[stagedActionIds[1]];
|
delete actionsById[stagedActionIds[1]];
|
||||||
skippedActionIds = skippedActionIds.filter(id => id !== stagedActionIds[0]);
|
skippedActionIds = skippedActionIds.filter(id => id !== stagedActionIds[1]);
|
||||||
stagedActionIds = [0].concat(stagedActionIds.slice(2));
|
stagedActionIds = [0].concat(stagedActionIds.slice(2));
|
||||||
committedState = computedStates[1].state;
|
committedState = computedStates[1].state;
|
||||||
computedStates = computedStates.slice(1);
|
computedStates = computedStates.slice(1);
|
||||||
|
|
|
@ -300,27 +300,30 @@ describe('instrument', () => {
|
||||||
let configuredLiftedStore;
|
let configuredLiftedStore;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
configuredStore = createStore(counter, instrument(undefined, { maxAge: 2 }));
|
configuredStore = createStore(counter, instrument(undefined, { maxAge: 3 }));
|
||||||
configuredLiftedStore = configuredStore.liftedStore;
|
configuredLiftedStore = configuredStore.liftedStore;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove earliest action when maxAge is reached', () => {
|
it('should auto-commit earliest non-@@INIT action when maxAge is reached', () => {
|
||||||
|
configuredStore.dispatch({ type: 'INCREMENT' });
|
||||||
configuredStore.dispatch({ type: 'INCREMENT' });
|
configuredStore.dispatch({ type: 'INCREMENT' });
|
||||||
let liftedStoreState = configuredLiftedStore.getState();
|
let liftedStoreState = configuredLiftedStore.getState();
|
||||||
|
|
||||||
expect(configuredStore.getState()).toBe(1);
|
expect(configuredStore.getState()).toBe(2);
|
||||||
expect(Object.keys(liftedStoreState.actionsById).length).toBe(2);
|
expect(Object.keys(liftedStoreState.actionsById).length).toBe(3);
|
||||||
expect(liftedStoreState.committedState).toBe(undefined);
|
expect(liftedStoreState.committedState).toBe(undefined);
|
||||||
|
expect(liftedStoreState.stagedActionIds).toInclude(1);
|
||||||
|
|
||||||
|
// Triggers auto-commit.
|
||||||
configuredStore.dispatch({ type: 'INCREMENT' });
|
configuredStore.dispatch({ type: 'INCREMENT' });
|
||||||
liftedStoreState = configuredLiftedStore.getState();
|
liftedStoreState = configuredLiftedStore.getState();
|
||||||
|
|
||||||
expect(configuredStore.getState()).toBe(2);
|
expect(configuredStore.getState()).toBe(3);
|
||||||
expect(Object.keys(liftedStoreState.actionsById).length).toBe(2);
|
expect(Object.keys(liftedStoreState.actionsById).length).toBe(3);
|
||||||
expect(liftedStoreState.stagedActionIds).toExclude(0);
|
expect(liftedStoreState.stagedActionIds).toExclude(1);
|
||||||
expect(liftedStoreState.computedStates[0].state).toBe(1);
|
expect(liftedStoreState.computedStates[0].state).toBe(1);
|
||||||
expect(liftedStoreState.committedState).toBe(1);
|
expect(liftedStoreState.committedState).toBe(1);
|
||||||
expect(liftedStoreState.currentStateIndex).toBe(1);
|
expect(liftedStoreState.currentStateIndex).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle skipped actions', () => {
|
it('should handle skipped actions', () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user