Skip to content

Instantly share code, notes, and snippets.

@erichulburd
Created December 23, 2017 00:40
Show Gist options
  • Save erichulburd/0a6fcc1be897bb658e3ff2d2676c2675 to your computer and use it in GitHub Desktop.
Save erichulburd/0a6fcc1be897bb658e3ff2d2676c2675 to your computer and use it in GitHub Desktop.
context('game is paused', () => {
afterEach(() => {
Observable.interval.restore();
});
it(`interval starts when user starts game and is stopped when end emitted`, () => {
const testScheduler = new TestScheduler((actual, expected) => {
expect(actual).to.deep.equal(expected);
});
const interval$ = testScheduler.createColdObservable('--a--b--c', {
a: 0,
b: 1,
c: 2
});
sinon.stub(Observable, 'interval').returns(interval$);
const store = {
getState: () => ({
game: { /* game is paused */ }
})
};
const action$ = new ActionsObservable(
testScheduler.createHotObservable('a-----b', {
a: actions.start.click(),
b: actions.end()
})
);
const test$ = game(action$, store);
testScheduler.expectObservable(test$).toBe('a-b--b', {
a: actions.start()
b: actions.incrementTime()
});
testScheduler.flush();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment