arqex / freezer

A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
MIT License
1.28k stars 56 forks source link

Some strange failing test #63

Closed kuraga closed 8 years ago

kuraga commented 8 years ago

What's the difference between String and Numeric here? Add tests (maybe in other places, too) for this difference.

Thanks.

arqex commented 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.

kuraga commented 8 years ago

@arqex I updated code and text, re-read, please.

arqex commented 8 years ago

Thanks @kuraga

Currently I am on holidays, I'll have a look at it when I came back :)

arqex commented 8 years ago

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' );
kuraga commented 8 years ago

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.

Oh, @arqex , NOW I really see! Thanks!

P.S. I just don't know: is this documented/tested?