Trying out immutable-js, I found something that I don't fully understand and want to make sure I'm using set correctly.
Basically, if you use "set()" to set a value of a property with an object or array, it stores a raw object/array, whereas if you use merge, it does what I'd expect, converting the raw array to an immutable list.
So my question is: Should you avoid using set() with objects/arrays for parameter 2?
Jasmine Test example here:
it("can do a thing you shouldn't do(?) - inject a normal object into a Map via set", function(){
const expected = fromJS({ a: [ 3, 4, 5 ] });
const set_value = expected.set("a", [3, 4,5]);
const merge_value = expected.merge({"a": [3, 4,5]});
expect(expected.get("a")).toEqualImmutable(set_value.get("a")); // Fails
expect(expected.get("a")).toEqualImmutable(merge_value.get("a")); // Passes
})
Output is:
Message:
Expected
List [ 3, 4, 5 ]
to equal
3,4,5