Skip to content

Instantly share code, notes, and snippets.

@cakeinpanic
Last active October 7, 2017 22:15
Show Gist options
  • Save cakeinpanic/00417392f801ded993e35da78d95da41 to your computer and use it in GitHub Desktop.
Save cakeinpanic/00417392f801ded993e35da78d95da41 to your computer and use it in GitHub Desktop.
gist for medium
class MyService {
constructor(private customInterval = 1000) {
}
someMethod() {
Observable.interval(this.customInterval)
.subscribe(() => {
this.logger.logObservable();
});
setInterval(() => {
this.logger.logInterval();
}, this.customInterval * .5);
}
}
it('someMethod would be ran with iterator each second', (done) => {
let myService = new MyService(10);
myService.someMethod();
setTimeout(() => {
expect(logger.logObservable).toHaveBeenCalledTimes(2);
expect(logger.logInterval).toHaveBeenCalledTimes(1);
done();
}, 2 * 10);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment