Skip to content

Commit 29c07b7

Browse files
committed
Update ValueFetcherTests to use Turbine
Signed-off-by: matt-ramotar <[email protected]>
1 parent dffc852 commit 29c07b7

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed
Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
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.flow.flow
67
import kotlinx.coroutines.flow.flowOf
78
import kotlinx.coroutines.test.TestScope
89
import kotlinx.coroutines.test.runTest
9-
import org.mobilenativefoundation.store.store5.util.assertEmitsExactly
1010
import kotlin.test.Test
11+
import kotlin.test.assertEquals
1112

1213
@ExperimentalCoroutinesApi
1314
@FlowPreview
@@ -18,7 +19,11 @@ class ValueFetcherTests {
1819
fun givenValueFetcherWhenInvokeThenResultIsWrapped() =
1920
testScope.runTest {
2021
val fetcher = Fetcher.ofFlow<Int, Int> { flowOf(it * it) }
21-
assertEmitsExactly(fetcher(3), listOf(FetcherResult.Data(value = 9)))
22+
23+
fetcher(3).test {
24+
assertEquals(FetcherResult.Data(value = 9), awaitItem())
25+
awaitComplete()
26+
}
2227
}
2328

2429
@Test
@@ -31,21 +36,21 @@ class ValueFetcherTests {
3136
throw e
3237
}
3338
}
34-
assertEmitsExactly(
35-
fetcher(3),
36-
listOf(FetcherResult.Error.Exception(e)),
37-
)
39+
fetcher(3).test {
40+
assertEquals(FetcherResult.Error.Exception(e), awaitItem())
41+
awaitComplete()
42+
}
3843
}
3944

4045
@Test
4146
fun givenNonFlowValueFetcherWhenInvokeThenResultIsWrapped() =
4247
testScope.runTest {
4348
val fetcher = Fetcher.of<Int, Int> { it * it }
4449

45-
assertEmitsExactly(
46-
fetcher(3),
47-
listOf(FetcherResult.Data(value = 9)),
48-
)
50+
fetcher(3).test {
51+
assertEquals(FetcherResult.Data(value = 9), awaitItem())
52+
awaitComplete()
53+
}
4954
}
5055

5156
@Test
@@ -56,6 +61,9 @@ class ValueFetcherTests {
5661
Fetcher.of<Int, Int> {
5762
throw e
5863
}
59-
assertEmitsExactly(fetcher(3), listOf(FetcherResult.Error.Exception(e)))
64+
fetcher(3).test {
65+
assertEquals(FetcherResult.Error.Exception(e), awaitItem())
66+
awaitComplete()
67+
}
6068
}
6169
}

0 commit comments

Comments
 (0)