Skip to content

Commit

Permalink
add support for expect(spy).nthCalledWith(int, args...)
Browse files Browse the repository at this point in the history
  • Loading branch information
elad_yosifon committed Feb 18, 2018
1 parent 4e4a9e0 commit 64605fb
Show file tree
Hide file tree
Showing 3 changed files with 507 additions and 80 deletions.
297 changes: 297 additions & 0 deletions packages/expect/src/__tests__/__snapshots__/spy_matchers.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,221 @@ Expected mock function to not have been last called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`lastCalledWith works with many arguments 2`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.lastCalledWith(</><green>expected</><dim>)</>

Expected mock function to not have been last called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`lastCalledWith works with many arguments 3`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.lastCalledWith(</><green>expected</><dim>)</>

Expected mock function to not have been last called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`lastCalledWith works with many arguments 4`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.lastCalledWith(</><green>expected</><dim>)</>

Expected mock function to not have been last called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`lastCalledWith works with many arguments that don't match 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).lastCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been last called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>."
`;

exports[`lastCalledWith works with many arguments that don't match 2`] = `
"<dim>expect(</><red>jest.fn()</><dim>).lastCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been last called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>."
`;

exports[`lastCalledWith works with many arguments that don't match 3`] = `
"<dim>expect(</><red>jest.fn()</><dim>).lastCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been last called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>."
`;

exports[`lastCalledWith works with many arguments that don't match 4`] = `
"<dim>expect(</><red>jest.fn()</><dim>).lastCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been last called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>."
`;

exports[`lastCalledWith works with trailing undefined arguments 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).lastCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been last called with:
Did not expect argument 2 but it was called with <red>undefined</>."
`;

exports[`nthCalledWith nthCalledWith 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[\\"foo1\\", \\"bar\\"]</>"
`;

exports[`nthCalledWith nthCalledWith 2`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[\\"foo1\\", \\"bar\\"]</>"
`;

exports[`nthCalledWith nthCalledWith 3`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[\\"foo1\\", \\"bar\\"]</>"
`;

exports[`nthCalledWith nthCalledWith 4`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[\\"foo1\\", \\"bar\\"]</>"
`;

exports[`nthCalledWith should reject non integer nth value 1`] = `"nth value must be a positive integer greater than 0"`;

exports[`nthCalledWith should reject non integer nth value 2`] = `"nth value must be a positive integer greater than 0"`;

exports[`nthCalledWith should reject non integer nth value 3`] = `"nth value must be a positive integer greater than 0"`;

exports[`nthCalledWith should reject non integer nth value 4`] = `"nth value must be a positive integer greater than 0"`;

exports[`nthCalledWith should reject nth value smaller than 1 1`] = `"nth value must be a positive integer greater than 0"`;

exports[`nthCalledWith should reject nth value smaller than 1 2`] = `"nth value must be a positive integer greater than 0"`;

exports[`nthCalledWith should reject nth value smaller than 1 3`] = `"nth value must be a positive integer greater than 0"`;

exports[`nthCalledWith should reject nth value smaller than 1 4`] = `"nth value must be a positive integer greater than 0"`;

exports[`nthCalledWith should replace 1st, 2nd, 3rd with first, second, third 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to have been called with:
"
`;

exports[`nthCalledWith should replace 1st, 2nd, 3rd with first, second, third 2`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[\\"foo1\\", \\"bar\\"]</>"
`;

exports[`nthCalledWith should replace 1st, 2nd, 3rd with first, second, third 3`] = `
"<dim>expect(</><red>jest.fn()</><dim>).nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to have been called with:
"
`;

exports[`nthCalledWith should replace 1st, 2nd, 3rd with first, second, third 4`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[\\"foo1\\", \\"bar\\"]</>"
`;

exports[`nthCalledWith should replace 1st, 2nd, 3rd with first, second, third 5`] = `
"<dim>expect(</><red>jest.fn()</><dim>).nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to have been called with:
"
`;

exports[`nthCalledWith should replace 1st, 2nd, 3rd with first, second, third 6`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[\\"foo1\\", \\"bar\\"]</>"
`;

exports[`nthCalledWith should replace 1st, 2nd, 3rd with first, second, third 7`] = `
"<dim>expect(</><red>jest.fn()</><dim>).nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to have been called with:
"
`;

exports[`nthCalledWith should replace 1st, 2nd, 3rd with first, second, third 8`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[\\"foo1\\", \\"bar\\"]</>"
`;

exports[`nthCalledWith works when not called 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to have been called with:
<green>[\\"foo\\", \\"bar\\"]</>
But it was <red>not called</>."
`;

exports[`nthCalledWith works with Immutable.js objects 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[Immutable.Map {\\"a\\": {\\"b\\": \\"c\\"}}, Immutable.Map {\\"a\\": {\\"b\\": \\"c\\"}}]</>"
`;

exports[`nthCalledWith works with Map 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[Map {1 => 2, 2 => 1}]</>"
`;

exports[`nthCalledWith works with Map 2`] = `
"<dim>expect(</><red>jest.fn()</><dim>).nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to have been called with:
<green>Map {\\"a\\" => \\"b\\", \\"b\\" => \\"a\\"}</> as argument 1, but it was called with <red>Map {1 => 2, 2 => 1}</>."
`;

exports[`nthCalledWith works with Set 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[Set {1, 2}]</>"
`;

exports[`nthCalledWith works with Set 2`] = `
"<dim>expect(</><red>jest.fn()</><dim>).nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to have been called with:
<green>Set {3, 4}</> as argument 1, but it was called with <red>Set {1, 2}</>."
`;

exports[`nthCalledWith works with arguments that don't match 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to have been called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar1\\"</>."
`;

exports[`nthCalledWith works with arguments that match 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.nthCalledWith(</><green>expected</><dim>)</>

Expected mock function first call to not have been called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`nthCalledWith works with trailing undefined arguments 1`] = `"nth value must be a positive integer greater than 0"`;

exports[`toBeCalled works only on spies or jest.fn 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>)[.not].toBeCalled(</><dim>)</>

Expand Down Expand Up @@ -298,6 +499,27 @@ Expected mock function not to have been called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`toHaveBeenCalledWith works with many arguments 2`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.toHaveBeenCalledWith(</><green>expected</><dim>)</>

Expected mock function not to have been called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`toHaveBeenCalledWith works with many arguments 3`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.toHaveBeenCalledWith(</><green>expected</><dim>)</>

Expected mock function not to have been called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`toHaveBeenCalledWith works with many arguments 4`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.toHaveBeenCalledWith(</><green>expected</><dim>)</>

Expected mock function not to have been called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`toHaveBeenCalledWith works with many arguments that don't match 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).toHaveBeenCalledWith(</><green>expected</><dim>)</>

Expand All @@ -309,6 +531,39 @@ Expected mock function to have been called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar1\\"</>."
`;

exports[`toHaveBeenCalledWith works with many arguments that don't match 2`] = `
"<dim>expect(</><red>jest.fn()</><dim>).toHaveBeenCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>.

<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar2\\"</>.

<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar1\\"</>."
`;

exports[`toHaveBeenCalledWith works with many arguments that don't match 3`] = `
"<dim>expect(</><red>jest.fn()</><dim>).toHaveBeenCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>.

<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar2\\"</>.

<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar1\\"</>."
`;

exports[`toHaveBeenCalledWith works with many arguments that don't match 4`] = `
"<dim>expect(</><red>jest.fn()</><dim>).toHaveBeenCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>.

<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar2\\"</>.

<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar1\\"</>."
`;

exports[`toHaveBeenCalledWith works with trailing undefined arguments 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).toHaveBeenCalledWith(</><green>expected</><dim>)</>

Expand Down Expand Up @@ -388,13 +643,55 @@ Expected mock function to not have been last called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`toHaveBeenLastCalledWith works with many arguments 2`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.toHaveBeenLastCalledWith(</><green>expected</><dim>)</>

Expected mock function to not have been last called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`toHaveBeenLastCalledWith works with many arguments 3`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.toHaveBeenLastCalledWith(</><green>expected</><dim>)</>

Expected mock function to not have been last called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`toHaveBeenLastCalledWith works with many arguments 4`] = `
"<dim>expect(</><red>jest.fn()</><dim>).not.toHaveBeenLastCalledWith(</><green>expected</><dim>)</>

Expected mock function to not have been last called with:
<green>[\\"foo\\", \\"bar\\"]</>"
`;

exports[`toHaveBeenLastCalledWith works with many arguments that don't match 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).toHaveBeenLastCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been last called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>."
`;

exports[`toHaveBeenLastCalledWith works with many arguments that don't match 2`] = `
"<dim>expect(</><red>jest.fn()</><dim>).toHaveBeenLastCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been last called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>."
`;

exports[`toHaveBeenLastCalledWith works with many arguments that don't match 3`] = `
"<dim>expect(</><red>jest.fn()</><dim>).toHaveBeenLastCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been last called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>."
`;

exports[`toHaveBeenLastCalledWith works with many arguments that don't match 4`] = `
"<dim>expect(</><red>jest.fn()</><dim>).toHaveBeenLastCalledWith(</><green>expected</><dim>)</>

Expected mock function to have been last called with:
<green>\\"bar\\"</> as argument 2, but it was called with <red>\\"bar3\\"</>."
`;

exports[`toHaveBeenLastCalledWith works with trailing undefined arguments 1`] = `
"<dim>expect(</><red>jest.fn()</><dim>).toHaveBeenLastCalledWith(</><green>expected</><dim>)</>

Expand Down
Loading

0 comments on commit 64605fb

Please sign in to comment.