Last active
October 7, 2017 22:15
-
-
Save cakeinpanic/00417392f801ded993e35da78d95da41 to your computer and use it in GitHub Desktop.
gist for medium
This file contains 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
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