11package org.mobilenativefoundation.store.store5
22
3+ import app.cash.turbine.test
34import kotlinx.coroutines.ExperimentalCoroutinesApi
45import kotlinx.coroutines.FlowPreview
56import kotlinx.coroutines.async
@@ -9,7 +10,6 @@ import kotlinx.coroutines.flow.toList
910import kotlinx.coroutines.test.TestScope
1011import kotlinx.coroutines.test.runTest
1112import org.mobilenativefoundation.store.store5.util.FakeFetcher
12- import org.mobilenativefoundation.store.store5.util.assertEmitsExactly
1313import kotlin.test.Test
1414import 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