Skip to content

Instantly share code, notes, and snippets.

@cakeinpanic
Last active October 8, 2017 07:16
Show Gist options
  • Save cakeinpanic/85e0a21dacc149ea81fdddd3d2129016 to your computer and use it in GitHub Desktop.
Save cakeinpanic/85e0a21dacc149ea81fdddd3d2129016 to your computer and use it in GitHub Desktop.
gist for medium
it('someMethod would be ran with iterator each second', () => {
const clock = <any>sinon.useFakeTimers(0);
myService.someMethod();
clock.tick(2 * 1000);
expect(logger.logObservable).toHaveBeenCalledTimes(2);
expect(logger.logInterval).toHaveBeenCalledTimes(1);
// tell sinon to restore global timers for other tests
clock.restore();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment