Last active
June 27, 2018 04:00
-
-
Save cartant/272151dbb3ffcc9b41ad6da258cd6080 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { expect } from "chai"; | |
| import { fakeSchedulers } from "rxjs-marbles/mocha"; | |
| import { timer } from "rxjs"; | |
| import * as sinon from "sinon"; | |
| describe("timer", () => { | |
| let clock: sinon.SinonFakeTimers; | |
| beforeEach(() => { | |
| clock = sinon.useFakeTimers(); | |
| }); | |
| it("should be testable with fake time", fakeSchedulers(() => { | |
| let received: number | undefined; | |
| timer(100).subscribe(value => received = value); | |
| clock.tick(50); | |
| expect(received).to.be.undefined; | |
| clock.tick(50); | |
| expect(received).to.equal(0); | |
| })); | |
| afterEach(() => { | |
| clock.restore(); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment