【发布时间】:2016-06-02 00:04:12
【问题描述】:
我正在阅读和练习教程:http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html 但我无法通过减速器测试。然后我做了一个新的测试来找出原因。
这是 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']
}));
});
});
无论是使用Map还是fromJS,测试都没有通过
如果选择“地图”,则显示:
AssertionError: expected 'Map { "entries": Trainspotting }' to equal 'Map { "entries": Trainspotting }'
+ expected - actual
如果选择“fromJS”,则显示:
AssertionError: expected 'Map { "entries": Trainspotting }' to equal 'Map { "entries": List [ "Trainspotting" ] }'
+ expected - actual
-Map { "entries": Trainspotting }
+Map { "entries": List [ "Trainspotting" ] }
这真是令人困惑。如何让它发挥作用?
【问题讨论】:
标签: reactjs mocha.js immutability redux immutable.js