Hey guys, using Orbit's testing framework, how can...
# orbit-mvi
b
Hey guys, using Orbit's testing framework, how can I test this?
Copy code
containerHost.assert( initialState ) {
    states({ dataFromCache })             // first state
    refreshCache()                        // update cache
    states({ updatedDataFromCache }).     // updated state emitted AFTER cache update
}
For some reason the 1st option fails fails, but if I run the following it passes:
Copy code
refreshCache() 
containerHost.assert( initialState ) {
    states({ dataFromCache }, { updatedDataFromCache })
}
However, the 2nd option doesn't guarantee that the second state was only emitted after the
refreshCache()
function was called. It feels like there's no way to assert the timing at which new states are emitted using the
states
function. Any idea?
a
you'd have to break it down into two checks, one where you don't call refreshCache and verify that the datafromcache is the only state, and then one with the call and expected states
@Mikolaj Leszczynski, can't remember if this would work?
assert
really just waits for the required number of states right each time
Copy code
containerHost.assert( initialState ) {
    states({ dataFromCache })             // first state
}

refreshCache()                        // update cache

containerHost.assert( initialState ) {
    states({ dataFromCache })             // first state
    states({ updatedDataFromCache }).     // updated state emitted AFTER cache update
}
šŸ‘ 3
b
ah yes this works thanks
m
Yeah there is no other way to do a partial assertion currently!