I haben node/redux benutze ich folgendes haben, während sie mit chai Prüfung:unveränderliche Chai Assertion Fehler während erwartet equals führen
AssertionError: expected 'Map { "winos": List [ Map { "id": 1, "x": 1, "y": 1, "movable": false }, Map { "id": 2, "x": 2, "y": 2, "movable": false }, Map { "id": 5, "x": 5, "y": 5, "movable": false } ] }'
to equal 'Map { "winos": List [ Map { "id": 1, "x": 1, "y": 1, "movable": false }, Map { "id": 2, "x": 2, "y": 2, "movable": false }, Map { "id": 5, "x": 5, "y": 5, "movable": false } ] }'
I haben gesehen, daß dies ein bekannter Fehler ist: https://github.com/astorije/chai-immutable/issues/24. Die Person dort schaffte es, dies zu lösen, indem sie alles im Baum unveränderlich machte, aber ich denke, dass ich bereits alles unveränderlich habe.
Mein Code ist unten:
import {List, Map} from 'immutable';
import {expect} from 'chai';
export function addWino(state, wino) {
return state.updateIn(['winos'], arr => arr.push(wino));
}
describe('setWinos',() => {
describe('addWino',() => {
it('adds a Wino',() => {
const wino = Map({
id: 5,
x:5,
y:5,
movable: false
});
const nextState = addWino(state, wino);
expect(nextState).to.equal(Map({
winos: List.of([
Map({
id: 1,
x:1,
y:1,
movable: false
})
],
[
Map({
id: 2,
x:2,
y:2,
movable: false
})
],
[
Map({
id: 5,
x:5,
y:5,
movable: false
})
])
}));
});
});
}
Ich habe auch schon versucht .eql()
und .to.deep.equal()
. Danke für Ihre Hilfe.
Sie sollten diese Antwort als Lösung Ihrer Frage markieren, da dies in der Tat das Problem war :) – astorije