I'm attempting to migrate a React/Redux app to Immutable.JS
and have a question about testing.
Given a reducer which does something like this:
export default (state = initialState, action) => {
switch (action.type) {
case RUN_ENDED:
return state.set('isRunning', false)
.set('roundResult', action.data)
default:
return state
}
I would like to test that both properties have been set correctly.
My old tests would have looked like this:
it('should handle the RUN_ENDED action', () => {
const action = {
type: RUN_ENDED,
data: {
winnerId: 0
}
}
const result = simulatorReducer(undefined, action)
expect(result).to.deep.equal({
isRunning: false,
roundResult: action.data
})
})
With Immutable I don't seem able to do these comparisons in quite the same way. I can explicitly check each value in result
with result.get('theProperty')
but this seems a bit laborious if I have 5-6 values.
Is there some way to do this with Immutable?
Aucun commentaire:
Enregistrer un commentaire