Hi,
First of all, it appears (and it makes sense) that key order in an immutable Map with primitive fields does not matter, as illustrated by the following test:
it('Key order for Maps with primitive fields does not matter', ()=>{
const simpleMap = Map({
loaded: false,
working: true
});
expect(simpleMap).to.equal(Map({ // key order different
working: true,
loaded: false
}));
})
However, if an immutable Map contains one or more key with plain object in it will cause equality to fail if the order of keys is different, as illustrated in the following test (notice I use to.eql, not to.equal):
it('Map field data order matters!!', ()=>{
const map = Map({
loaded: false,
working: true,
message: {first_name: 'john', last_name: 'due'}
});
expect(map).to.eql(Map({ // key order the same
loaded: false,
working: true,
message: {first_name: 'john', last_name: 'due'}
}));
expect(map).to.eql(Map({ // key order different
working: true,
loaded: false,
message: {first_name: 'john', last_name: 'due'}
}));
})
The second expect fails.
Is that an intended behavior or a bug in chai-immutable?
Thanks,
Alex
PS. I am using chai-immutable v. 1.3.0.
Hi,
First of all, it appears (and it makes sense) that key order in an immutable Map with primitive fields does not matter, as illustrated by the following test:
However, if an immutable Map contains one or more key with plain object in it will cause equality to fail if the order of keys is different, as illustrated in the following test (notice I use
to.eql, notto.equal):The second
expectfails.Is that an intended behavior or a bug in chai-immutable?
Thanks,
Alex
PS. I am using chai-immutable v. 1.3.0.