【发布时间】:2017-09-21 23:20:15
【问题描述】:
我正在关注这个使用 Immutable 的 redux 教程 - http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html,试图制作我自己的应用程序版本以更好地理解 Immutable 和 Redux,但我不明白为什么我的测试失败了。 Mocha 的输出显示预期值是相同的,但我认为订单可能导致测试失败。但是 Mocha 的输出并没有显示 List 对象的实际顺序。 List.of() 是对象数组的正确方法吗?
core_spec.js
import {List, Map} from 'immutable';
import {expect} from 'chai';
import {initAlbums, next, rate} from '../src/core';
describe('application logic', () => {
describe('initAlbums', () => {
it('adds the albums to the state', () => {
const state = Map();
const albums = List.of({'Album 1': null}, {'Album 2': null}, {'Album 3': null});
const nextState = initAlbums(state, albums);
expect(nextState).to.deep.equal(Map({
albums: List.of({'Album 1': null}, {'Album 2': null}, {'Album 3': null})
}));
});
});
});
core.js
import {List, Map} from 'immutable';
export function initAlbums(state, albums) {
return state.set('albums', List(albums));
}
摩卡输出
1 failing
1) application logic initAlbums adds the albums to the state:
AssertionError: expected 'Map { "albums": List [ [object Object], [object Object], [object Object] ] }' to equal 'Map { "albums": List [ [object Object], [object Object], [object Object] ] }'
+ expected - actual
【问题讨论】:
标签: redux mocha.js immutable.js