Skip to content

Commit

Permalink
Add test cases for toMatchObject() with circular object
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo Selig committed Jul 9, 2019
1 parent a501718 commit 0974497
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/expect/src/__tests__/matchers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,11 @@ describe('toMatchObject()', () => {
});
});

const circularObject = {};
circularObject.self = circularObject;
const transitiveCircularObject = {};
transitiveCircularObject.up = {down: transitiveCircularObject};

[
[{a: 'b', c: 'd'}, {e: 'b'}],
[{a: 'b', c: 'd'}, {a: 'b!', c: 'd'}],
Expand All @@ -1597,6 +1602,8 @@ describe('toMatchObject()', () => {
[[1, 2, 3], [1, 2, 2]],
[new Error('foo'), new Error('bar')],
[Object.assign(Object.create(null), {a: 'b'}), {c: 'd'}],
[circularObject, circularObject],
[transitiveCircularObject, transitiveCircularObject],
].forEach(([n1, n2]) => {
it(`{pass: false} expect(${stringify(n1)}).toMatchObject(${stringify(
n2,
Expand Down

0 comments on commit 0974497

Please sign in to comment.