Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@erichulburd
Created December 23, 2017 00:42
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 erichulburd/c34e0734689b7699ff7c89bdb4032a9c to your computer and use it in GitHub Desktop.
Save erichulburd/c34e0734689b7699ff7c89bdb4032a9c to your computer and use it in GitHub Desktop.
// ...
it('does not restart game when ongoing and emits end event when user loses', () => {
const testScheduler = new TestScheduler((actual, expected) => {
expect(actual).to.deep.equal(expected);
});
const interval$ = testScheduler.createColdObservable('--a--b', {
a: 0,
a: 1
});
sinon.stub(Observable, 'interval').returns(interval$);
const action$ = new ActionsObservable(
// Our overly eager user has started the game twice!
testScheduler.createHotObservable('aa', {
a: actions.start.click()
})
);
const store = {
getState: () => ({})
};
const getState = sinon.stub(store, 'getState');
const now = moment();
[
// ...
].forEach((gameState, i) => getState.onCall(i).returns({ game: gameState }));
const test$ = game(action$, store);
testScheduler.expectObservable(test$).toBe('a-b--(bc)', {
a: actions.start(),
b: actions.incrementTime(),
c: actions.end()
});
testScheduler.flush();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment