I’m testing a flow with turbine and I wonder if there is a better way to do this :
Copy code
sealed class SideEffect {
data class Effect1(val someValue: String) : SideEffect()
Effect2 : SideEffect()
}
val mutableSharedFlow = MutableSharedFlow<SideEffect>(replay = 0)
flowOfSideEffects.test {
mutableSharedFlow.emit(Effect1("test")
assertTrue((awaitEvent() as Event.Item).value is CustomerScreenSideEffect.NavigateToCustomerDetails)
}
Now
awaitEvent()
returns a value of type
Event<SideEffect>
rather than just a
SideEffect
like
expectItem
did, if I remember correctly. So my question is, is there a better way to down cast the value returned
awaitEvent
?
j
jw
08/24/2021, 12:16 PM
Use awaitItem to get a single item
j
jean
08/24/2021, 12:34 PM
oh god I wasn’t awake enough to notice the autocompletion didn’t gave me the correct method. Thanks!