Tests: raise default timeout of consumeItemsUntilPredicate to 3 seconds (like awaitItem)
This commit is contained in:
parent
dbba95a830
commit
9d6f68ac82
2 changed files with 3 additions and 3 deletions
|
|
@ -85,7 +85,6 @@ import kotlinx.coroutines.test.TestScope
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.time.Duration.Companion.seconds
|
|
||||||
|
|
||||||
class RoomListPresenterTests {
|
class RoomListPresenterTests {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
|
|
@ -167,7 +166,7 @@ class RoomListPresenterTests {
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
presenter.present()
|
presenter.present()
|
||||||
}.test {
|
}.test {
|
||||||
val initialState = consumeItemsUntilPredicate(timeout = 3.seconds) { state -> state.contentState is RoomListContentState.Skeleton }.last()
|
val initialState = consumeItemsUntilPredicate { state -> state.contentState is RoomListContentState.Skeleton }.last()
|
||||||
assertThat(initialState.contentState).isInstanceOf(RoomListContentState.Skeleton::class.java)
|
assertThat(initialState.contentState).isInstanceOf(RoomListContentState.Skeleton::class.java)
|
||||||
roomListService.postAllRoomsLoadingState(RoomList.LoadingState.Loaded(1))
|
roomListService.postAllRoomsLoadingState(RoomList.LoadingState.Loaded(1))
|
||||||
roomListService.postAllRooms(
|
roomListService.postAllRooms(
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import app.cash.turbine.withTurbineTimeout
|
||||||
import io.element.android.libraries.core.bool.orFalse
|
import io.element.android.libraries.core.bool.orFalse
|
||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consume all items until timeout is reached waiting for an event or we receive terminal event.
|
* Consume all items until timeout is reached waiting for an event or we receive terminal event.
|
||||||
|
|
@ -48,7 +49,7 @@ suspend fun <T : Any> ReceiveTurbine<T>.awaitLastSequentialItem(): T {
|
||||||
* @return the list of consumed items.
|
* @return the list of consumed items.
|
||||||
*/
|
*/
|
||||||
suspend fun <T : Any> ReceiveTurbine<T>.consumeItemsUntilPredicate(
|
suspend fun <T : Any> ReceiveTurbine<T>.consumeItemsUntilPredicate(
|
||||||
timeout: Duration = 100.milliseconds,
|
timeout: Duration = 3.seconds,
|
||||||
ignoreTimeoutError: Boolean = false,
|
ignoreTimeoutError: Boolean = false,
|
||||||
predicate: (T) -> Boolean,
|
predicate: (T) -> Boolean,
|
||||||
): List<T> {
|
): List<T> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue