Pin create: add test for presenter

This commit is contained in:
ganfra 2023-10-19 15:45:11 +02:00
parent 3a4d32f79d
commit e88a5fc858
9 changed files with 142 additions and 15 deletions

View file

@ -32,6 +32,16 @@ suspend fun <T : Any> ReceiveTurbine<T>.consumeItemsUntilTimeout(timeout: Durati
return consumeItemsUntilPredicate(timeout) { false }
}
/**
* Consume all items which are emitted sequentially.
* Use the smallest timeout possible internally to avoid wasting time.
* Same as calling skipItems(x) and then awaitItem() but without assumption on the number of items.
* @return the last item emitted.
*/
suspend fun <T : Any> ReceiveTurbine<T>.awaitLastSequentialItem(): T {
return consumeItemsUntilTimeout(1.milliseconds).last()
}
/**
* Consume items until predicate is true, or timeout is reached waiting for an event, or we receive terminal event.
* The timeout is applied for each event.