Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ kotlin {
js(IR) {
browser { testTask { useMocha { timeout = "10min" } } }
nodejs { testTask { useMocha { timeout = "10min" } } }

useEsModules()
binaries.library()
generateTypeScriptDefinitions()
}
Expand Down
14 changes: 7 additions & 7 deletions src/jsTest/kotlin/co/pokeapi/pokekotlin/test/LiveJsTest.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package co.pokeapi.pokekotlin.test

import co.pokeapi.pokekotlin.PokeApi
import io.ktor.client.plugins.*
import io.ktor.http.*
import io.ktor.client.plugins.ClientRequestException
import io.ktor.http.HttpStatusCode
import kotlin.js.Promise
import kotlin.test.Test
import kotlin.test.assertEquals
Expand All @@ -12,12 +12,12 @@ import kotlinx.coroutines.test.runTest

@Suppress("UnusedVariable", "unused")
class LiveJsTest {
private val client: PokeApi =
js("require('./pokekotlin.js').co.pokeapi.pokekotlin.PokeApi.Default")
private val client: Promise<PokeApi> =
js("import('./pokekotlin.mjs').then(function (it) { return it.PokeApi.Default; })")

@Test
fun resource() = runTest {
val client = client
val client = client.await()
assertEquals(
"sitrus",
js("client.getBerryAsync(10).then(function (it) { return it.name; })")
Expand All @@ -28,7 +28,7 @@ class LiveJsTest {

@Test
fun list() = runTest {
val client = client
val client = client.await()

val berry1 =
js("client.getBerryListAsync(0, 10).then(function (it) { return it.results[5]; })")
Expand All @@ -45,7 +45,7 @@ class LiveJsTest {

@Test
fun notFound() = runTest {
val client = client
val client = client.await()

val exception =
assertFailsWith<ClientRequestException> {
Expand Down
Loading