私はReduxをピックアップしようとしています。私が従うチュートリアルはImmutableJsを使用しています。私は完全にImmutableJsに新しいですし、ちょうど行くAPIのドキュメントに行っています。私の練習アプリはチュートリアルよりはるかに複雑なので、少し離れて道を離れてしまったかもしれません。Immutablejs Map.updateはユニットテストを中断します
Map.update()メソッドを使用するたびに、コードを正常にテストする方法が見つけられません。ここで私が間違っているかを把握しようとして書いたテストがある:
import chai, {expect} from 'chai';
import chaiImmutable from 'chai-immutable';
import {List, Map} from 'immutable';
chai.use(chaiImmutable);
describe("Immutable Test Issues",() => {
it("should present accurate immutable equality",() => {
// -- Maps with Lists match just fine
const a1 = Map({ test: 1, args: List([1, 2]) });
const a2 = Map({ test: 1, args: List([1, 2]) });
expect(a1).to.equal(a2); // pass
// -- Maps with Lists of Maps match just fine
const ba = { pid: 100, arg: 2 };
const bb = { pid: 101, arg: 5 };
const b1 = Map({ test: 1, args: List([Map(ba), Map(bb)]) });
const b2 = Map({ test: 1, args: List([Map(ba), Map(bb)]) });
expect(b1).to.equal(b2); // pass
// -- using Map.update()
const ea = { pid: 100, arg: 2 };
const eb = { pid: 101, arg: 4 };
const e1 = Map({ test: 1 }).update('args', List(), l => l.push([Map(ea), Map(eb)]));
const e2 = Map({ test: 1 }).update('args', List(), l => l.push([Map(ea), Map(eb)]));
expect(e1).to.equal(e2); // fail
expect(e1.get('args')).to.equal(List().push([Map(ea), Map(eb)])); // fail
});
});
私は次のように使用しています:
- ノード:V6.3.1およびv4.4.0(別のワークステーション)
- モカ:V3.0.2
- チャイ:v3.5.0
- チャイ-不変:V1.6.0
- 不変:v3.8.1
- バベルコア:v6.13.2
- バベル・プリセット・es2015:6.13.2
私の他のテストでは、これまでのところ、私はMap.update()
を使用する場合にのみ、私はこの問題で終わるか、細かい渡しています。私はまだこの方法が使われているチュートリアルでは見たことがありませんが、それはかなり基本的なもので、私はそれがうまくいくと期待しています。
うまくすべての作品にあなたは、あなたの質問の解決としてあなた自身の答えをマークしなければならない:) – astorije