Skip to content

Commit

Permalink
Change tests in jest-each
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark1626 committed Feb 3, 2020
1 parent 2f9de45 commit 420e565
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 18 deletions.
28 changes: 24 additions & 4 deletions packages/jest-each/src/__tests__/__snapshots__/array.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ Instead was called with: undefined
"
`;

exports[`jest-each .it.concurrent throws an error when called with an empty array 1`] = `"Cannot read property 'mock' of undefined"`;

exports[`jest-each .it.concurrent throws an error when not called with an array 1`] = `"Cannot read property 'mock' of undefined"`;

exports[`jest-each .it.only throws an error when called with an empty array 1`] = `
"Error: \`.each\` called with an empty Array of table data.
"
Expand Down Expand Up @@ -100,6 +96,30 @@ Instead was called with: undefined
"
`;

exports[`jest-each .test.concurrent.only throws an error when called with an empty array 1`] = `
"Error: \`.each\` called with an empty Array of table data.
"
`;

exports[`jest-each .test.concurrent.only throws an error when not called with an array 1`] = `
"\`.each\` must be called with an Array or Tagged Template Literal.
Instead was called with: undefined
"
`;

exports[`jest-each .test.concurrent.skip throws an error when called with an empty array 1`] = `
"Error: \`.each\` called with an empty Array of table data.
"
`;

exports[`jest-each .test.concurrent.skip throws an error when not called with an array 1`] = `
"\`.each\` must be called with an Array or Tagged Template Literal.
Instead was called with: undefined
"
`;

exports[`jest-each .test.only throws an error when called with an empty array 1`] = `
"Error: \`.each\` called with an empty Array of table data.
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,6 @@ exports[`jest-each .it throws error when there are no arguments for given headin
"
`;
exports[`jest-each .it.concurrent throws an error when called with an empty string 1`] = `"Cannot read property 'mock' of undefined"`;
exports[`jest-each .it.concurrent throws error when there are fewer arguments than headings over multiple rows 1`] = `"Cannot read property 'mock' of undefined"`;
exports[`jest-each .it.concurrent throws error when there are fewer arguments than headings when given one row 1`] = `"Cannot read property 'mock' of undefined"`;
exports[`jest-each .it.concurrent throws error when there are no arguments for given headings 1`] = `"Cannot read property 'mock' of undefined"`;
exports[`jest-each .it.only throws an error when called with an empty string 1`] = `
"Error: \`.each\` called with an empty Tagged Template Literal of table data.
"
Expand Down Expand Up @@ -320,6 +312,84 @@ exports[`jest-each .test.concurrent throws error when there are no arguments for
"
`;
exports[`jest-each .test.concurrent.only throws an error when called with an empty string 1`] = `
"Error: \`.each\` called with an empty Tagged Template Literal of table data.
"
`;
exports[`jest-each .test.concurrent.only throws error when there are fewer arguments than headings over multiple rows 1`] = `
"Not enough arguments supplied for given headings:
<green>a | b | expected</>
Received:
<red>Array [</>
<red> 0,</>
<red> 1,</>
<red> 1,</>
<red> 1,</>
<red> 1,</>
<red>]</>
Missing <red>2</> arguments"
`;
exports[`jest-each .test.concurrent.only throws error when there are fewer arguments than headings when given one row 1`] = `
"Not enough arguments supplied for given headings:
<green>a | b | expected</>
Received:
<red>Array [</>
<red> 0,</>
<red> 1,</>
<red>]</>
Missing <red>2</> arguments"
`;
exports[`jest-each .test.concurrent.only throws error when there are no arguments for given headings 1`] = `
"Error: \`.each\` called with a Tagged Template Literal with no data, remember to interpolate with \${expression} syntax.
"
`;
exports[`jest-each .test.concurrent.skip throws an error when called with an empty string 1`] = `
"Error: \`.each\` called with an empty Tagged Template Literal of table data.
"
`;
exports[`jest-each .test.concurrent.skip throws error when there are fewer arguments than headings over multiple rows 1`] = `
"Not enough arguments supplied for given headings:
<green>a | b | expected</>
Received:
<red>Array [</>
<red> 0,</>
<red> 1,</>
<red> 1,</>
<red> 1,</>
<red> 1,</>
<red>]</>
Missing <red>2</> arguments"
`;
exports[`jest-each .test.concurrent.skip throws error when there are fewer arguments than headings when given one row 1`] = `
"Not enough arguments supplied for given headings:
<green>a | b | expected</>
Received:
<red>Array [</>
<red> 0,</>
<red> 1,</>
<red>]</>
Missing <red>2</> arguments"
`;
exports[`jest-each .test.concurrent.skip throws error when there are no arguments for given headings 1`] = `
"Error: \`.each\` called with a Tagged Template Literal with no data, remember to interpolate with \${expression} syntax.
"
`;
exports[`jest-each .test.only throws an error when called with an empty string 1`] = `
"Error: \`.each\` called with an empty Tagged Template Literal of table data.
"
Expand Down
10 changes: 7 additions & 3 deletions packages/jest-each/src/__tests__/array.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,24 @@ const getGlobalTestMocks = () => {
};
globals.test.only = jest.fn();
globals.test.skip = jest.fn();
globals.test.concurrent = jest.fn();
globals.test.concurrent.only = jest.fn();
globals.test.concurrent.skip = jest.fn();
globals.it.only = jest.fn();
globals.it.skip = jest.fn();
globals.describe.only = jest.fn();
globals.describe.skip = jest.fn();
globals.test.concurrent = jest.fn();
globals.it.concurrent = jest.fn();
return globals;
};

describe('jest-each', () => {
[
['test'],
['test', 'concurrent'],
['test', 'concurrent', 'only'],
['test', 'concurrent', 'skip'],
['test', 'only'],
['it'],
['it', 'concurrent'],
['fit'],
['it', 'only'],
['describe'],
Expand Down Expand Up @@ -293,6 +295,7 @@ describe('jest-each', () => {
test.each([
[['test']],
[['test', 'only']],
[['test', 'concurrent', 'only']],
[['it']],
[['fit']],
[['it', 'only']],
Expand Down Expand Up @@ -331,6 +334,7 @@ describe('jest-each', () => {
[
['xtest'],
['test', 'skip'],
['test', 'concurrent', 'skip'],
['xit'],
['it', 'skip'],
['xdescribe'],
Expand Down
10 changes: 7 additions & 3 deletions packages/jest-each/src/__tests__/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,24 @@ const getGlobalTestMocks = () => {
};
globals.test.only = jest.fn();
globals.test.skip = jest.fn();
globals.test.concurrent = jest.fn();
globals.test.concurrent.only = jest.fn();
globals.test.concurrent.skip = jest.fn();
globals.it.only = jest.fn();
globals.it.skip = jest.fn();
globals.describe.only = jest.fn();
globals.describe.skip = jest.fn();
globals.test.concurrent = jest.fn();
globals.it.concurrent = jest.fn();
return globals;
};

describe('jest-each', () => {
[
['test'],
['test', 'concurrent'],
['test', 'concurrent', 'only'],
['test', 'concurrent', 'skip'],
['test', 'only'],
['it'],
['it', 'concurrent'],
['fit'],
['it', 'only'],
['describe'],
Expand Down Expand Up @@ -319,6 +321,7 @@ describe('jest-each', () => {
test.each([
[['test']],
[['test', 'only']],
[['test', 'concurrent', 'only']],
[['it']],
[['fit']],
[['it', 'only']],
Expand Down Expand Up @@ -365,6 +368,7 @@ describe('jest-each', () => {
[
['xtest'],
['test', 'skip'],
['test', 'concurrent', 'skip'],
['xit'],
['it', 'skip'],
['xdescribe'],
Expand Down

0 comments on commit 420e565

Please sign in to comment.