mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 19:57:04 +05:30
feat(android): migrate away from kotest
This commit is contained in:
parent
ae66aced83
commit
ea40650214
2 changed files with 49 additions and 36 deletions
|
@ -74,7 +74,13 @@ dependencies {
|
|||
|
||||
kapt(libs.dagger.compiler)
|
||||
|
||||
testImplementation(libs.kotest.assertions.core)
|
||||
testImplementation(libs.kotest.runner.junit5)
|
||||
testImplementation(libs.junit.jupiter.api)
|
||||
testImplementation(libs.truth) { exclude(group = "junit", module = "junit") }
|
||||
testRuntimeOnly(libs.junit.jupiter.engine)
|
||||
testRuntimeOnly(libs.junit.legacy) {
|
||||
// See https://github.com/google/truth/issues/333
|
||||
because("Truth needs it")
|
||||
}
|
||||
testImplementation(libs.kotlinx.coroutines.test)
|
||||
testImplementation(libs.okhttp.mockwebserver)
|
||||
}
|
||||
|
|
|
@ -6,34 +6,40 @@
|
|||
*/
|
||||
package dev.msfjarvis.claw.android.viewmodel
|
||||
|
||||
import io.kotest.core.spec.Spec
|
||||
import io.kotest.core.spec.style.FunSpec
|
||||
import io.kotest.matchers.shouldBe
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.mockwebserver.Dispatcher
|
||||
import okhttp3.mockwebserver.MockResponse
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import okhttp3.mockwebserver.RecordedRequest
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class CSRFRepositoryTest : FunSpec() {
|
||||
private val server = MockWebServer()
|
||||
|
||||
init {
|
||||
test("Correctly extracts CSRF token").config(coroutineTestScope = true) {
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class CSRFRepositoryTest {
|
||||
@Test
|
||||
fun `correctly extracts CSRF token`() = runTest {
|
||||
val repo =
|
||||
CSRFRepository(
|
||||
OkHttpClient.Builder().build(),
|
||||
Dispatchers.Default,
|
||||
server.url("/").toString(),
|
||||
)
|
||||
repo.extractToken() shouldBe
|
||||
assertThat(repo.extractToken())
|
||||
.isEqualTo(
|
||||
"OZWykgFemPVeOSNmB53-ccKXe458X7xCInO1-qzFU6nk_9RCSrSQqS9OPmA5_pyy8qD3IYAIZ7XfAM3gdhJpkQ"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun beforeSpec(spec: Spec) {
|
||||
super.beforeSpec(spec)
|
||||
companion object {
|
||||
private val server = MockWebServer()
|
||||
|
||||
@JvmStatic
|
||||
@BeforeAll
|
||||
fun setup() {
|
||||
val dispatcher =
|
||||
object : Dispatcher() {
|
||||
override fun dispatch(request: RecordedRequest): MockResponse {
|
||||
|
@ -53,4 +59,5 @@ class CSRFRepositoryTest : FunSpec() {
|
|||
}
|
||||
server.dispatcher = dispatcher
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue