My tests are failing due to different object insta...
# orbit-mvi
h
My tests are failing due to different object instances even though the side effects are same.
Copy code
Expected :
[LoadingSideEffects$NavigateToLandingPage@4bc90c14]
Actual   :
[LoadingSideEffects$NavigateToLandingPage@46a28b7f]
My side effect -:
Copy code
class NavigateToLandingPage(val id:String) : LoadingSideEffects()
However when I try the same on side effects with no parameters, then the tests are passing e.g
Copy code
object NavigateToLandingPage : LoadingSideEffects()
The latter will pass, however the former will fail. For assertion, I am using
Copy code
viewModel.assert(initialState = initialState) {
    postedSideEffects(
        LoadingSideEffects.NavigateToLandingPage(scheduleId)
    )
}
This fails. If I use,
Copy code
val result = viewmodel.testIntent {
    fetchStatus(id)
}

assert(result.sideEffectObserver.values.first() is LoadingSideEffects.NavigateToLandingPage)
This passes Is this (result.sideEffectObserver.values.first()) the right way to test? And does it mean that we cannot use the format.
Copy code
viewModel.assert(initialState = initialState) { }
when our side effect accepts some values/parameters?
o
class instances are not the same. Use
data class NavigateToLandingPage
instead
h
Edited please check.
Copy code
val result = viewmodel.testIntent {
    fetchStatus(id)
}

assert(result.sideEffectObserver.values.first() is LoadingSideEffects.NavigateToLandingPage)
Asserting like this worked.
You are right, my bad, I should have used data class instead of a normal class.