I’m testing a flow with turbine and I wonder if th...
# squarelibraries
j
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
Use awaitItem to get a single item
j
oh god I wasn’t awake enough to notice the autocompletion didn’t gave me the correct method. Thanks!