Skip to content

Commit

Permalink
ngrx#853 more tests for lock/pause
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Apr 3, 2018
1 parent 51a0c08 commit 52b2362
Showing 1 changed file with 73 additions and 1 deletion.
74 changes: 73 additions & 1 deletion modules/store-devtools/spec/extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ function createOptions(

function createState(
actionsById?: LiftedActions,
computedStates?: ComputedState[]
computedStates?: ComputedState[],
isLocked = false,
isPaused = false
) {
return {
monitorState: null,
Expand All @@ -60,6 +62,8 @@ function createState(
error: null,
},
],
isLocked,
isPaused,
};
}

Expand Down Expand Up @@ -344,4 +348,72 @@ describe('DevtoolsExtension', () => {
});
});
});

describe('with locked recording', () => {
beforeEach(() => {
devtoolsExtension = new DevtoolsExtension(
reduxDevtoolsExtension,
createConfig({})
);
// Subscription needed or else extension connection will not be established.
devtoolsExtension.actions$.subscribe(() => null);
});

it('should not notify extension of PERFORM_ACTIONs', () => {
const action = new PerformAction({ type: 'ACTION' });
const state = createState(undefined, undefined, true);

devtoolsExtension.notify(action, state);
expect(extensionConnection.send).not.toHaveBeenCalled();
expect(reduxDevtoolsExtension.send).not.toHaveBeenCalled();
});

it('should notify extension of actions that require full state update', () => {
const action = {} as LiftedAction;
const state = createState(undefined, undefined, true);
const options = createOptions();

devtoolsExtension.notify(action, state);
expect(extensionConnection.send).not.toHaveBeenCalled();
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith(
null,
state,
options
);
});
});

describe('with paused recording', () => {
beforeEach(() => {
devtoolsExtension = new DevtoolsExtension(
reduxDevtoolsExtension,
createConfig({})
);
// Subscription needed or else extension connection will not be established.
devtoolsExtension.actions$.subscribe(() => null);
});

it('should not notify extension of PERFORM_ACTIONs', () => {
const action = new PerformAction({ type: 'ACTION' });
const state = createState(undefined, undefined, undefined, true);

devtoolsExtension.notify(action, state);
expect(extensionConnection.send).not.toHaveBeenCalled();
expect(reduxDevtoolsExtension.send).not.toHaveBeenCalled();
});

it('should notify extension of actions that require full state update', () => {
const action = {} as LiftedAction;
const state = createState(undefined, undefined, undefined, true);
const options = createOptions();

devtoolsExtension.notify(action, state);
expect(extensionConnection.send).not.toHaveBeenCalled();
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith(
null,
state,
options
);
});
});
});

0 comments on commit 52b2362

Please sign in to comment.