Skip to content

Instantly share code, notes, and snippets.

@CharlieHess
Last active September 30, 2017 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CharlieHess/4df00ef65ed43a32b4a7708d2be59e3b to your computer and use it in GitHub Desktop.
Save CharlieHess/4df00ef65ed43a32b4a7708d2be59e3b to your computer and use it in GitHub Desktop.
A test for the workspace usage epic
import { rxSandbox } from 'rx-sandbox';
import { tallyWorkspaceUsageEpic } from '../epics/tally-workspace-usage';
describe('tallyWorkspaceUsageEpic', () => {
it('should accumulate time until the app is quit', () => {
const { hot, flush, getMessages, e } = rxSandbox.create();
const w = { type: WORKSPACE.SELECTION_CHANGED, payload: 'Hiro' };
const x = { type: WORKSPACE.SELECTION_CHANGED, payload: 'Fiona' };
const y = { type: WORKSPACE.SELECTION_CHANGED, payload: 'Da5id' };
const z = { type: APP.QUIT };
const usageAction = {
type: WORKSPACE.UPDATE_USAGE,
payload: { 'Hiro': 60, 'Fiona': 40, 'Da5id': 20 }
};
const action$ = hot('w-----x---y-z', { w, x, y, z });
const expected = e( '------------(x|)', { x: usageAction });
const result = getMessages(
tallyWorkspaceUsageEpic(action$, store)
);
flush();
expect(result).to.deep.equal(expected);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment