Reputation: 29
I'm reading and practicing the tutorial: http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html But I couldn't get reducer tests passed. Then I made a new test to find out the reason.
Here's the test.js(mocha with chai):
import {expect} from 'chai';
import {List, Map, fromJS} from 'immutable';
describe('set', () => {
it('sets map\'s property', () => {
const state = Map();
const action = {type: 'SET_ENTRIES', entries: ['Trainspotting']};
const nextState = state.set('entries', action.entries);
/*
expect(nextState).to.equal(Map({
entries: ['Trainspotting']
}));
*/
expect(nextState).to.equal(fromJS({
entries: ['Trainspotting']
}));
});
});
Either use Map or fromJS, the test doesn't pass
If choose "Map", it shows:
AssertionError: expected 'Map { "entries": Trainspotting }' to equal 'Map { "entries": Trainspotting }'
+ expected - actual
If choose "fromJS", it shows:
AssertionError: expected 'Map { "entries": Trainspotting }' to equal 'Map { "entries": List [ "Trainspotting" ] }'
+ expected - actual
-Map { "entries": Trainspotting }
+Map { "entries": List [ "Trainspotting" ] }
It's really confusing. How to make it work?
Upvotes: 0
Views: 42
Reputation: 1089
Did you try
const nextState = state.set('entries', List(action.entries));
Upvotes: 1