Skip to content

Commit

Permalink
fixes #70
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip Clark committed Apr 25, 2017
1 parent 5d6df24 commit af99304
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/issue-70.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var deepDiff = require("../");

var left = {foo: undefined};
var right = {};

console.log(deepDiff.diff(left, right));
2 changes: 2 additions & 0 deletions index.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ function deepDiff(lhs, rhs, changes, prefilter, path, key, stack) {
if (ltype === 'undefined') {
if (rtype !== 'undefined') {
changes(new DiffNew(currentPath, rhs));
} else {
changes(new DiffDeleted(currentPath, lhs));
}
} else if (rtype === 'undefined') {
changes(new DiffDeleted(currentPath, lhs));
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ function deepDiff(lhs, rhs, changes, prefilter, path, key, stack) {
if (ltype === 'undefined') {
if (rtype !== 'undefined') {
changes(new DiffNew(currentPath, rhs));
} else {
changes(new DiffDeleted(currentPath, lhs));
}
} else if (rtype === 'undefined') {
changes(new DiffDeleted(currentPath, lhs));
Expand Down
20 changes: 20 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,4 +563,24 @@ describe('deep-diff', function() {
expect(deep.diff(lhs, rhs)).to.be(undefined);
});
});

describe('regression test for issue #70', function() {
var lhs = {foo: undefined };
var rhs = {}

it('should detect a difference', function() {
var diff = deep.diff(lhs, rhs);

expect(diff.length).to.be(1);

expect(diff[0].kind).to.be('D');
expect(diff[0].path).to.be.an('array');
expect(diff[0].path).to.have.length(1);
expect(diff[0].path[0]).to.be('foo');
expect(diff[0].lhs).to.be(undefined);

});
});


});

1 comment on commit af99304

@lrdevries
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`var left = {foo: undefined};
var right = {foo: undefined};

console.log(deepDiff.diff(left, right));`

Does also triggers a deletion, eventhrough they are simular.

Please sign in to comment.