Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for expect(spy).nthCalledWith(int, args...) #5605

Merged
merged 2 commits into from
Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
302 changes: 302 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,226 @@ 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`] = `
"<dim>expect(</><red>jest.fn()</><dim>).nthCalledWith(</><green>expected</><dim>)</>

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

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 +504,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 +536,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 +648,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