Use async tests on Kotlin/JS with Kotlin version 1.2.20-eap-33
diff --git a/js/kotlinx-coroutines-core-js/src/test/kotlin/kotlinx/coroutines/experimental/PromiseTest.kt b/js/kotlinx-coroutines-core-js/src/test/kotlin/kotlinx/coroutines/experimental/PromiseTest.kt
index b5c058f..5f9414c 100644
--- a/js/kotlinx-coroutines-core-js/src/test/kotlin/kotlinx/coroutines/experimental/PromiseTest.kt
+++ b/js/kotlinx-coroutines-core-js/src/test/kotlin/kotlinx/coroutines/experimental/PromiseTest.kt
@@ -19,8 +19,6 @@
import kotlin.js.Promise
import kotlin.test.*
-// :todo: This test does not actually test anything because of KT-21970 JS: Support async tests in Mocha and others
-// One should watch for errors in the console to see if there were any failures (the test would still pass)
class PromiseTest : TestBase() {
@Test
fun testPromiseResolvedAsDeferred() = promise {
@@ -33,10 +31,13 @@
@Test
fun testPromiseRejectedAsDeferred() = promise {
+ lateinit var promiseReject: (Throwable) -> Unit
val promise = Promise<String> { _, reject ->
- reject(TestException("Rejected"))
+ promiseReject = reject
}
val deferred = promise.asDeferred()
+ // reject after converting to deferred to avoid "Unhandled promise rejection" warnings
+ promiseReject(TestException("Rejected"))
try {
deferred.await()
expectUnreached()