Updated on 2026-08-14
This commit is contained in:
parent
09c52231e2
commit
3cc0a643e9
40 changed files with 77 additions and 71 deletions
|
|
@ -4,8 +4,10 @@ plugins {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.core.utils)
|
||||
implementation(deps.arrow.core)
|
||||
|
||||
api(deps.androidx.datastore.core)
|
||||
api(deps.test.coroutine)
|
||||
api(deps.test.junit5)
|
||||
api(deps.test.mockk)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.tangem.test.core
|
||||
|
||||
import com.tangem.utils.coroutines.AppCoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
class TestAppCoroutineScope(override val coroutineContext: CoroutineContext = Dispatchers.Unconfined) : AppCoroutineScope {
|
||||
|
||||
constructor(testScope: TestScope) : this(testScope.coroutineContext)
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.tangem.test.core.datastore
|
||||
|
||||
import androidx.datastore.core.DataStore
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.updateAndGet
|
||||
|
||||
class MockStateDataStore<T>(default: T) : DataStore<T> {
|
||||
|
||||
private val _data = MutableStateFlow(value = default)
|
||||
override val data: Flow<T> = _data
|
||||
|
||||
override suspend fun updateData(transform: suspend (t: T) -> T): T {
|
||||
return _data.updateAndGet { transform(it) }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue