Skip to content

Commit

Permalink
Add failing tests for #58
Browse files Browse the repository at this point in the history
#58
"Comparing object with "hasOwnProperty" keys fails"
  • Loading branch information
anko authored and mattphillips committed Jan 25, 2022
1 parent ff1235e commit ca791b3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/added/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,13 @@ describe('.addedDiff', () => {
expect(addedDiff(lhs, rhs)).toEqual({ date: new Date('2016') });
});
});

describe('object with non-function hasOwnProperty property', () => {
test('can represent the property in diff despite it being part of Object.prototype', () => {
const lhs = {};
const rhs = { hasOwnProperty: true };
expect(addedDiff(lhs, rhs)).toEqual({ hasOwnProperty: true });
});
});
});
});
8 changes: 8 additions & 0 deletions src/deleted/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,13 @@ describe('.deletedDiff', () => {
expect(deletedDiff({ date: new Date('2016') }, rhs)).toEqual({ date: undefined });
});
});

describe('object with non-function hasOwnProperty property', () => {
test('can represent the property in diff despite it being part of Object.prototype', () => {
const lhs = { hasOwnProperty: true };
const rhs = {};
expect(deletedDiff(lhs, rhs)).toEqual({ hasOwnProperty: undefined });
});
});
});
});
8 changes: 8 additions & 0 deletions src/updated/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,13 @@ describe('.updatedDiff', () => {
expect(updatedDiff(lhs, rhs)).toEqual({ date: new Date('2017') });
});
});

describe('object with non-function hasOwnProperty property', () => {
test('can represent the property in diff despite it being part of Object.prototype', () => {
const lhs = { hasOwnProperty: false };
const rhs = { hasOwnProperty: true };
expect(updatedDiff(lhs, rhs)).toEqual({ hasOwnProperty: true });
});
});
});
});

0 comments on commit ca791b3

Please sign in to comment.