Skip to content

Commit

Permalink
Ditch kotest
Browse files Browse the repository at this point in the history
  • Loading branch information
kiri committed May 23, 2024
1 parent 5f5fc4d commit a3b87c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 38 deletions.
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/com/ouroboros/dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ object Libs {
object Kotlin {
private const val version = "1.9.22"
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version"
const val testJUnit = "org.jetbrains.kotlin:kotlin-test-junit:$version"
}

object Coroutines {
Expand Down
5 changes: 2 additions & 3 deletions test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ android {

dependencies {
api project(':core')
implementation (Libs.Kotest.assertions){
exclude group: 'org.jetbrains.kotlin'
}
implementation(Libs.junit)
implementation(Libs.Kotlin.testJUnit)
}

afterEvaluate {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.bridge.ouroboros.compose.test

import io.kotest.assertions.withClue
import io.kotest.matchers.Matcher
import io.kotest.matchers.MatcherResult
import io.kotest.matchers.collections.shouldBeEmpty
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder
import kotlin.test.junit.JUnitAsserter.assertEquals
import kotlin.test.junit.JUnitAsserter.assertTrue

class EffectMatching<E>(
capturedEvents: Set<E>
Expand All @@ -18,15 +15,11 @@ class EffectMatching<E>(
}

fun expectEvents(vararg events: E) {
withClue("Expected events to be $events") {
emittedEvents shouldContainExactlyInAnyOrder events.toSet()
}
assertEquals("Expected events to be $events", events.toSet(), emittedEvents)
}

fun expectNoEvents() {
withClue("Expected events to be empty") {
emittedEvents.shouldBeEmpty()
}
assertTrue("Expected events to be empty", emittedEvents.isEmpty())
}

operator fun invoke(block: EffectMatching<E>.() -> Unit) {
Expand All @@ -40,11 +33,3 @@ class EffectMatching<E>(
}
}
}

fun <E> haveNoEvents() = object : Matcher<EffectResult<E>> {
override fun test(value: EffectResult<E>) = MatcherResult(
value.events.isEmpty(),
{ "Effect should not have emitted any events but were ${value.events}" },
{ "Effect should have emitted at least one event but no events were sent" }
)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.bridge.ouroboros.compose.test

import com.bridge.ouroboros.compose.Next
import io.kotest.assertions.withClue
import io.kotest.matchers.collections.shouldBeEmpty
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder
import io.kotest.matchers.shouldBe
import kotlin.test.junit.JUnitAsserter.assertEquals
import kotlin.test.junit.JUnitAsserter.assertNull
import kotlin.test.junit.JUnitAsserter.assertTrue

class NextMatching<M, F>(private val next: Next<M, F>) {

Expand All @@ -30,35 +29,27 @@ class NextMatching<M, F>(private val next: Next<M, F>) {
}

fun shouldHaveModel(model: M) {
withClue("Expect new model to be $model") {
newModel shouldBe model
}
assertEquals("Expect new model to be $model", model, newModel)
}

fun shouldNotHaveModel() {
withClue("Expected no new model") {
newModel shouldBe null
}
assertNull("Expected no new model", newModel)
}

fun shouldHaveEffects(vararg effects: F) {
newEffects shouldEmit effects.toSet()
}

infix fun Set<F>.shouldEmit(effects: Set<F>) {
withClue("Expecting effects to be $effects") {
newEffects shouldContainExactlyInAnyOrder effects
}
assertEquals("Expecting effects to be $effects", effects, newEffects)
}

infix fun Set<F>.shouldEmit(effect: F) {
shouldEmit(setOf(effect))
}

fun shouldNotHaveEffects() {
withClue("No effects should be emitted") {
newEffects.shouldBeEmpty()
}
assertTrue("No effects should be emitted", newEffects.isEmpty())
}

fun shouldNotChange() {
Expand Down

0 comments on commit a3b87c2

Please sign in to comment.