diff --git a/build.gradle.kts b/build.gradle.kts index b64fff7..97acc1b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,6 @@ -buildscript { - repositories { - mavenCentral() - mavenLocal() - maven("https://oss.sonatype.org/content/repositories/snapshots") - } -} - -@Suppress("DSL_SCOPE_VIOLATION") plugins { alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.kotest.multiplatform) } repositories { @@ -18,28 +10,19 @@ repositories { } kotlin { - targets { - js(IR) { - browser { - testTask { - useMocha() - } - } - binaries.executable() - } + js(IR) { + nodejs() } sourceSets { val jsMain by getting { dependencies { - implementation(libs.ktor.client.js) + implementation(libs.ktor.client.js) } } val jsTest by getting { dependencies { implementation(libs.kotest.assertions.core) implementation(libs.kotest.framework.engine) - implementation(libs.kotest.framework.datatest) - implementation(libs.kotest.property) } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fbe5e4c..6134f17 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,13 +1,11 @@ [versions] -kotlin = "1.9.10" -kotest = "5.7.2" +kotlin = "2.0.0" +kotest = "5.10.0-LOCAL" ktor = "2.3.4" [libraries] kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" } kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" } -kotest-framework-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest" } -kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" } ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac72c34..b82aa23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..ceebae1 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,6 @@ +pluginManagement { + repositories { + gradlePluginPortal() + mavenLocal() + } +} diff --git a/src/jsTest/kotlin/io/kotest/examples/js/PropertyTests.kt b/src/jsTest/kotlin/io/kotest/examples/js/PropertyTests.kt deleted file mode 100644 index 20b879a..0000000 --- a/src/jsTest/kotlin/io/kotest/examples/js/PropertyTests.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.kotest.examples.js - -import io.kotest.core.spec.style.FunSpec -import io.kotest.matchers.shouldBe -import io.kotest.property.Exhaustive -import io.kotest.property.checkAll -import io.kotest.property.exhaustive.ints - -class PropertyTests : FunSpec({ - test("addition should be commutative") { - checkAll { a, b, c -> - a + b + c shouldBe c + b + a - } - } - - test("addition should be associative") { - checkAll { a, b -> - checkAll(Exhaustive.ints(1..100)) { c -> - (a + b) + c shouldBe a + (b + c) - } - } - } -}) diff --git a/src/jsTest/kotlin/io/kotest/examples/js/SsnTest.kt b/src/jsTest/kotlin/io/kotest/examples/js/SsnTest.kt index 77c4ed6..a06400e 100644 --- a/src/jsTest/kotlin/io/kotest/examples/js/SsnTest.kt +++ b/src/jsTest/kotlin/io/kotest/examples/js/SsnTest.kt @@ -2,14 +2,22 @@ package io.kotest.examples.js import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe +import kotlinx.coroutines.delay import validateSocial class SsnTest : FunSpec({ - test("a SSN should be invalid when it contains a zero in any position") { - validateSocial("543-23-5013") shouldBe false - validateSocial("043-23-5313") shouldBe false - validateSocial("313-03-5310") shouldBe false + context("js now allows nested tests") { + delay(1000) // look ma, I can use coroutines here ! + context("give me another context!") { + delay(1000) // look ma, I can use coroutines here ! + test("a SSN should be invalid when it contains a zero in any position") { + delay(1000) // look ma, I can use coroutines here too ! + validateSocial("543-23-5013") shouldBe false + validateSocial("043-23-5313") shouldBe false + validateSocial("313-03-5310") shouldBe false + } + } } test("a SSN should be invalid when it starts with 666") { diff --git a/src/jsTest/kotlin/io/kotest/examples/js/datatest.kt b/src/jsTest/kotlin/io/kotest/examples/js/datatest.kt deleted file mode 100644 index 52add7e..0000000 --- a/src/jsTest/kotlin/io/kotest/examples/js/datatest.kt +++ /dev/null @@ -1,35 +0,0 @@ -package io.kotest.examples.js - -import io.kotest.core.Tuple2 -import io.kotest.core.spec.style.FunSpec -import io.kotest.datatest.withData -import io.kotest.matchers.shouldBe - -data class PythagTriple(val a: Int, val b: Int, val c: Int) - -class DataTest : FunSpec({ - - withData( - PythagTriple(8, 15, 17), - PythagTriple(9, 12, 15), - PythagTriple(15, 20, 25), - ) { (a, b, c) -> - a * a + b * b shouldBe c * c - } - - test(PythagTriple(8, 15, 17).toString()) { - - } - - test("foo\\.json") { - - } - - withData( - nameFn = { it.a }, - Tuple2("a.json", "b"), - Tuple2("b.json", "c"), - ) { (a, b) -> - println(a) - } -}) diff --git a/src/jsTest/kotlin/io/kotest/js/config.kt b/src/jsTest/kotlin/io/kotest/js/config.kt new file mode 100644 index 0000000..4cc3739 --- /dev/null +++ b/src/jsTest/kotlin/io/kotest/js/config.kt @@ -0,0 +1,3 @@ +package io.kotest.js + +fun config() {}