Skip to content

Commit 9374168

Browse files
committed
test(prefer-expect-assertions): add cases for each
1 parent e452740 commit 9374168

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/rules/__tests__/prefer-expect-assertions.test.ts

+46
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,27 @@ ruleTester.run('prefer-expect-assertions (loops)', rule, {
515515
},
516516
],
517517
},
518+
{
519+
code: dedent`
520+
it.each([1, 2, 3])("returns numbers that are greater than four", () => {
521+
for (const number of getNumbers()) {
522+
expect(number).toBeGreaterThan(4);
523+
}
524+
});
525+
526+
it("is a number that is greater than four", () => {
527+
expect(number).toBeGreaterThan(4);
528+
});
529+
`,
530+
options: [{ onlyFunctionsWithExpectInLoop: true }],
531+
errors: [
532+
{
533+
messageId: 'haveExpectAssertions',
534+
column: 1,
535+
line: 1,
536+
},
537+
],
538+
},
518539
{
519540
code: dedent`
520541
it("returns numbers that are greater than four", () => {
@@ -637,6 +658,31 @@ ruleTester.run('prefer-expect-assertions (loops)', rule, {
637658
},
638659
],
639660
},
661+
{
662+
code: dedent`
663+
it.skip.each\`\`("it1", async () => {
664+
expect.hasAssertions();
665+
666+
for (const number of getNumbers()) {
667+
expect(number).toBeGreaterThan(4);
668+
}
669+
})
670+
671+
it("it1", () => {
672+
for (const number of getNumbers()) {
673+
expect(number).toBeGreaterThan(4);
674+
}
675+
})
676+
`,
677+
options: [{ onlyFunctionsWithExpectInLoop: true }],
678+
errors: [
679+
{
680+
messageId: 'haveExpectAssertions',
681+
column: 1,
682+
line: 9,
683+
},
684+
],
685+
},
640686
{
641687
code: dedent`
642688
it("it1", async () => {

0 commit comments

Comments
 (0)