Skip to content

Commit 69dfb6e

Browse files
committed
Update StreamWithoutSourceOfTruthTests to use Turbine
Signed-off-by: matt-ramotar <[email protected]>
1 parent 3f299b6 commit 69dfb6e

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

store/src/commonTest/kotlin/org/mobilenativefoundation/store/store5/StreamWithoutSourceOfTruthTests.kt

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.mobilenativefoundation.store.store5
22

3+
import app.cash.turbine.test
34
import kotlinx.coroutines.ExperimentalCoroutinesApi
45
import kotlinx.coroutines.FlowPreview
56
import kotlinx.coroutines.async
@@ -9,7 +10,6 @@ import kotlinx.coroutines.flow.toList
910
import kotlinx.coroutines.test.TestScope
1011
import kotlinx.coroutines.test.runTest
1112
import org.mobilenativefoundation.store.store5.util.FakeFetcher
12-
import org.mobilenativefoundation.store.store5.util.assertEmitsExactly
1313
import kotlin.test.Test
1414
import kotlin.test.assertEquals
1515

@@ -37,18 +37,22 @@ class StreamWithoutSourceOfTruthTests {
3737
).take(3).toList()
3838
}
3939
delay(1_000) // make sure the async block starts first
40-
assertEmitsExactly(
41-
pipeline.stream(StoreReadRequest.fresh(3)),
42-
listOf(
40+
pipeline.stream(StoreReadRequest.fresh(3)).test {
41+
assertEquals(
4342
StoreReadResponse.Loading(
4443
origin = StoreReadResponseOrigin.Fetcher(),
4544
),
45+
awaitItem()
46+
)
47+
48+
assertEquals(
4649
StoreReadResponse.Data(
4750
value = "three-2",
4851
origin = StoreReadResponseOrigin.Fetcher(),
4952
),
50-
),
51-
)
53+
awaitItem()
54+
)
55+
}
5256

5357
assertEquals(
5458
listOf(
@@ -88,18 +92,22 @@ class StreamWithoutSourceOfTruthTests {
8892
).take(3).toList()
8993
}
9094
delay(1_000) // make sure the async block starts first
91-
assertEmitsExactly(
92-
pipeline.stream(StoreReadRequest.fresh(3)),
93-
listOf(
95+
pipeline.stream(StoreReadRequest.fresh(3)).test {
96+
assertEquals(
9497
StoreReadResponse.Loading(
9598
origin = StoreReadResponseOrigin.Fetcher(),
9699
),
100+
awaitItem()
101+
)
102+
103+
assertEquals(
97104
StoreReadResponse.Data(
98105
value = "three-2",
99106
origin = StoreReadResponseOrigin.Fetcher(),
100107
),
101-
),
102-
)
108+
awaitItem()
109+
)
110+
}
103111

104112
assertEquals(
105113
listOf(

0 commit comments

Comments
 (0)