Skip to content

Commit

Permalink
added tests for strict equal
Browse files Browse the repository at this point in the history
  • Loading branch information
grosto committed Feb 14, 2019
1 parent 4576618 commit 52468e1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3309,6 +3309,41 @@ Expected: <green>{\\"test\\": {\\"a\\": 1, \\"b\\": 2}}</>
Received: <red>{\\"test\\": {\\"a\\": 1, \\"b\\": 2}}</>"
`;

exports[`.toStrictEqual() matches the expected snapshot when it fails 3`] = `
"<dim>expect(</><red>received</><dim>).toStrictEqual(</><green>expected</><dim>)</>

Difference:

<green>- Expected</>
<red>+ Received</>

<dim> Object {</>
<green>- \\"a\\": \\"x\\",</>
<green>- \\"b\\": Any<String>,</>
<red>+ \\"a\\": \\"a\\",</>
<red>+ \\"b\\": \\"b\\",</>
<dim> }</>"
`;

exports[`.toStrictEqual() matches the expected snapshot when it fails 4`] = `
"<dim>expect(</><red>received</><dim>).toStrictEqual(</><green>expected</><dim>)</>

Difference:

<green>- Expected</>
<red>+ Received</>

<green>- ObjectContaining {</>
<green>- \\"a\\": \\"x\\",</>
<green>- \\"b\\": Any<String>,</>
<red>+ Object {</>
<red>+ \\"a\\": \\"a\\",</>
<red>+ \\"b\\": \\"b\\",</>
<red>+ \\"c\\": \\"c\\",</>
<red>+ \\"d\\": \\"d\\",</>
<dim> }</>"
`;

exports[`toMatchObject() {pass: false} expect([0]).toMatchObject([-0]) 1`] = `
"<dim>expect(</><red>received</><dim>).toMatchObject(</><green>expected</><dim>)</>

Expand Down
19 changes: 19 additions & 0 deletions packages/expect/src/__tests__/matchers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,25 @@ describe('.toStrictEqual()', () => {
test: new TestClassA(1, 2),
}).not.toStrictEqual({test: new TestClassA(1, 2)}),
).toThrowErrorMatchingSnapshot();

expect(() =>
jestExpect({
a: 'a',
b: 'b',
}).toStrictEqual({
a: 'x',
b: expect.any(String),
}),
).toThrowErrorMatchingSnapshot();

expect(() =>
jestExpect({a: 'a', b: 'b', c: 'c', d: 'd'}).toStrictEqual(
expect.objectContaining({
a: 'x',
b: expect.any(String),
}),
),
).toThrowErrorMatchingSnapshot();
});

it('does not pass for different types', () => {
Expand Down

0 comments on commit 52468e1

Please sign in to comment.