Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergeTest expects objects to be equal which is the same object #133

Open
drager opened this issue Sep 15, 2015 · 1 comment
Open

mergeTest expects objects to be equal which is the same object #133

drager opened this issue Sep 15, 2015 · 1 comment

Comments

@drager
Copy link
Contributor

drager commented Sep 15, 2015

Hi!

This line:

expect(cache).to.deep.equals(expected);

will always be true because its the same object. Lodash _.merge() changes and returns the object which makes them the same.

  var expected = _.merge(cache, jsong.jsonGraph);
  console.log(cache === expected); // true

  var out = jsongMerge(cache, jsong);
  expect(cache).to.deep.equals(expected);

If you change the method to this:

  var expected = _.merge(_.clone(cache), jsong.jsonGraph);
  console.log(cache === expected); // false

  var out = jsongMerge(cache, jsong);
  expect(cache).to.deep.equals(expected);

Then two of the tests will fail.

@drager
Copy link
Contributor Author

drager commented Sep 16, 2015

So is this expected jsong here: https://github.com/Netflix/falcor-router/blob/master/test/unit/internal/jsongMerge.spec.js#L122-L135 correct or are you expecting wrong? Is the test wrong or is it the jsonMerge() method that are not working as intended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant