File tree 3 files changed +10
-12
lines changed
kmposable-core/src/commonTest/kotlin/com/labosu/kmposable
3 files changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,9 @@ import app.cash.turbine.test
6
6
import kotlinx.coroutines.ExperimentalCoroutinesApi
7
7
import kotlinx.coroutines.FlowPreview
8
8
import kotlinx.coroutines.cancel
9
+ import kotlinx.coroutines.delay
9
10
import kotlinx.coroutines.test.StandardTestDispatcher
10
11
import kotlinx.coroutines.test.TestScope
11
- import kotlinx.coroutines.test.runCurrent
12
12
import kotlinx.coroutines.test.runTest
13
13
import kotlin.test.BeforeTest
14
14
import kotlin.test.Test
@@ -35,7 +35,7 @@ class ScopedActionTests : StoreCoroutineTest() {
35
35
val effectScope = TestScope (StandardTestDispatcher ())
36
36
assertEquals(" " , awaitItem().testProperty)
37
37
testStore.send(TestAction .LongRunningScopedEffectAction (effectScope))
38
- testCoroutineScope.runCurrent( )
38
+ delay( 1 )
39
39
40
40
// the value should increment by 1
41
41
var property = awaitItem().testProperty.toInt()
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ package com.labosu.kmposable
4
4
5
5
import com.labosu.kmposable.internal.MutableStateFlowStore
6
6
import kotlinx.coroutines.ExperimentalCoroutinesApi
7
- import kotlinx.coroutines.test.runCurrent
7
+ import kotlinx.coroutines.delay
8
8
import kotlinx.coroutines.test.runTest
9
9
import kotlin.test.BeforeTest
10
10
import kotlin.test.Test
@@ -26,9 +26,8 @@ class StoreExceptionHandlingTests : StoreCoroutineTest() {
26
26
fun `reduce exception should be handled` () {
27
27
assertFailsWith<MutableStateFlowStore .Companion .ReducerException > {
28
28
testCoroutineScope.runTest {
29
- testStore.send(TestAction .ThrowExceptionAction ).also {
30
- testCoroutineScope.runCurrent()
31
- }
29
+ testStore.send(TestAction .ThrowExceptionAction )
30
+ delay(1 )
32
31
}
33
32
}
34
33
}
@@ -37,9 +36,8 @@ class StoreExceptionHandlingTests : StoreCoroutineTest() {
37
36
fun `effect exception should be handled` () {
38
37
assertFailsWith<MutableStateFlowStore .Companion .EffectException > {
39
38
testCoroutineScope.runTest {
40
- testStore.send(TestAction .StartExceptionThrowingEffectAction ).also {
41
- testCoroutineScope.runCurrent()
42
- }
39
+ testStore.send(TestAction .StartExceptionThrowingEffectAction )
40
+ delay(1 )
43
41
}
44
42
}
45
43
}
Original file line number Diff line number Diff line change 3
3
package com.labosu.kmposable
4
4
5
5
import kotlinx.coroutines.ExperimentalCoroutinesApi
6
- import kotlinx.coroutines.test.runCurrent
6
+ import kotlinx.coroutines.delay
7
7
import kotlinx.coroutines.test.runTest
8
8
import kotlin.test.BeforeTest
9
9
import kotlin.test.Test
@@ -26,7 +26,7 @@ class StoreReducerTests : StoreCoroutineTest() {
26
26
@Test
27
27
fun `reducer should be called exactly once if one action is sent` () = testCoroutineScope.runTest {
28
28
testStore.send(TestAction .DoNothingAction )
29
- testCoroutineScope.runCurrent( )
29
+ delay( 1 )
30
30
assertTrue { testReducer.reduceCount == 1 }
31
31
}
32
32
@@ -41,7 +41,7 @@ class StoreReducerTests : StoreCoroutineTest() {
41
41
)
42
42
43
43
actionList.forEach { testStore.send(it)}
44
- testCoroutineScope.runCurrent( )
44
+ delay( 100 )
45
45
46
46
// add the effect action
47
47
actionList.add(TestAction .DoNothingFromEffectAction )
You can’t perform that action at this time.
0 commit comments