Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.