-
-
Save ygnessin/ab5ad4f2b7c69b8cc93f458b2572766a to your computer and use it in GitHub Desktop.
Failed attempt at reproducing https://github.com/kosi-libs/MocKMP/issues/62
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.test.runTest | |
import kotlinx.serialization.Serializable | |
import org.kodein.mock.Mock | |
import org.kodein.mock.UsesMocks | |
import org.kodein.mock.tests.TestsWithMocks | |
import kotlin.test.Test | |
import kotlin.test.assertEquals | |
@UsesMocks(Foo::class) | |
class IsAnyJsCrash : TestsWithMocks() { | |
override fun setUpMocks() = injectMocks(mocker) | |
@Mock | |
lateinit var foo: Foo | |
@Test | |
fun crashesInJs() = runTest { | |
val testSubject = ThingThatHasFoo(foo) | |
val parameter = MyDataClass( | |
"uuid", | |
true, | |
) | |
everySuspending { foo.get(parameter) } returns parameter | |
val result = testSubject.get(parameter) | |
assertEquals(parameter, result) | |
verifyWithSuspend(exhaustive = true) { | |
foo.get(isAny()) | |
} | |
} | |
} | |
@Serializable | |
public data class MyDataClass( | |
val uuid: String, | |
val flag: Boolean, | |
) | |
interface Foo { | |
public suspend fun get(key: MyDataClass): MyDataClass | |
} | |
class ThingThatHasFoo internal constructor( | |
private val foo: Foo, | |
) { | |
public suspend fun get(key: MyDataClass): MyDataClass { | |
return foo.get(key) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment