marcinmoskala
01/24/2018, 8:24 AM@JsName("numberOfCallsInTimeTest")
fun `Periodic caller for 50ms is called around 20 times in 1 second`() {
val caller = PeriodicCaller.PeriodicCallerImpl()
var count = 0
runBlocking {
val job = caller.start(50) { count++ }
delay(1000)
job.cancel()
}
assertTrue(count in 17..23)
}
This test works well on JVM, but on JS it throws
stack: IllegalStateException: JS thread cannot be blocked, runBlocking { ... } cannot be waiting for its completion with timeout