Skip to content

Commit

Permalink
mapState tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hoc081098 committed Dec 8, 2024
1 parent e771c48 commit 3ebb41e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/commonTest/kotlin/com/hoc081098/flowext/MapStateTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package com.hoc081098.flowext

import com.hoc081098.flowext.utils.BaseTest
import com.hoc081098.flowext.utils.asserReadonlyStateFlow
import com.hoc081098.flowext.utils.assertReadonlyStateFlow
import com.hoc081098.flowext.utils.test
import kotlin.math.abs
import kotlin.test.Test
Expand All @@ -44,7 +44,7 @@ class MapStateTest : BaseTest() {
val source = MutableStateFlow(1)
val mapped: StateFlow<Int> = source.mapState { abs(it) + 1 }

asserReadonlyStateFlow(mapped, 42)
assertReadonlyStateFlow(mapped, 42)

launch {
mapped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ suspend inline fun <reified T : Throwable, R> assertFailsWith(

suspend fun Flow<Int>.sum() = fold(0) { acc, value -> acc + value }

inline fun <reified T> asserReadonlyStateFlow(stateFlow: StateFlow<T>, value: T) {
inline fun <reified T> assertReadonlyStateFlow(stateFlow: StateFlow<T>, value: T) {
assertFalse { stateFlow is MutableStateFlow<T> }
assertFails { (stateFlow as MutableStateFlow<T>).value = value }
}

0 comments on commit 3ebb41e

Please sign in to comment.