Coroutines test when two events are emitted and a state is set and reset
Code to Test
fun updateAccount() {
coroutineScope.launch {
startLoading()
val isAccountUpdated = updateAccountUseCase()
if (isAccountUpdated) {
navigator.navigateUp()
} else {
completeLoading()
// TODO: Show Error
}
}
}
For context
val refreshSignal: MutableSharedFlow = MutableSharedFlow(
replay = 0,
extraBufferCapacity = 1,
)
fun startLoading() {
isLoading = true
refreshSignal.tryEmit(Unit)...