Skip to content

Commit

Permalink
test(prefer-expect-assertions): add cases for each
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Jan 14, 2022
1 parent d13ba19 commit d897e81
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/rules/__tests__/prefer-expect-assertions.test.ts
Expand Up @@ -515,6 +515,27 @@ ruleTester.run('prefer-expect-assertions (loops)', rule, {
},
],
},
{
code: dedent`
it.each([1, 2, 3])("returns numbers that are greater than four", () => {
for (const number of getNumbers()) {
expect(number).toBeGreaterThan(4);
}
});
it("is a number that is greater than four", () => {
expect(number).toBeGreaterThan(4);
});
`,
options: [{ onlyFunctionsWithExpectInLoop: true }],
errors: [
{
messageId: 'haveExpectAssertions',
column: 1,
line: 1,
},
],
},
{
code: dedent`
it("returns numbers that are greater than four", () => {
Expand Down Expand Up @@ -637,6 +658,31 @@ ruleTester.run('prefer-expect-assertions (loops)', rule, {
},
],
},
{
code: dedent`
it.skip.each\`\`("it1", async () => {
expect.hasAssertions();
for (const number of getNumbers()) {
expect(number).toBeGreaterThan(4);
}
})
it("it1", () => {
for (const number of getNumbers()) {
expect(number).toBeGreaterThan(4);
}
})
`,
options: [{ onlyFunctionsWithExpectInLoop: true }],
errors: [
{
messageId: 'haveExpectAssertions',
column: 1,
line: 9,
},
],
},
{
code: dedent`
it("it1", async () => {
Expand Down

0 comments on commit d897e81

Please sign in to comment.