Closed kuraga closed 8 years ago
Hey @kuraga
Long time no see! :) I am glad you are still using freezer.
You are right about that non-strict comparison, it should be strict. I will update it and merge some of your tests, I think they are really valuable.
As for all that mess about deepEqual or equal or strictEqual, it is something that I should improve but I am so lazy about it. Some of the tests are made copying and pasting previous one, that's why there are some no-sense comparison in there.
@arqex I updated code and text, re-read, please.
Thanks @kuraga
Currently I am on holidays, I'll have a look at it when I came back :)
Hi Kuraga,
Thanks for the effort to make freezer.js a better library, your help is much appreciated!!
The first test you have created is failing because the first set
is a no-op. Since the attribute a
is already 1, nothing is changed and anotherData === data
.
// this is doing nothing
var anotherData = data.set('a', 1);
// `data` is still inside freeezer so this is updating `a`
// in the current freezer state
data.set('a', 'another');
// so this will fail
assert.strictEqual( updated.a, 1 );
The second test passes though:
// This update freezer's state
var anotherData = data.set('a', 'cat');
// This is hardly discouraged. `data` is now detached from freezer.
// Never try to modify detached data.
data.set('a', 'another');
// This is passing because the second `set` wasn't done
// inside the freezer store, and it changed nothing.
var updated = freezer.getData();
assert.strictEqual( updated.a, 'cat' );
The first test you have created is failing because the first
set
is a no-op. Since the attribute a is already1
, nothing is changed andanotherData === data
.
Oh, @arqex , NOW I really see! Thanks!
P.S. I just don't know: is this documented/tested?
What's the difference between String and Numeric here? Add tests (maybe in other places, too) for this difference.
Thanks.