From 484de057225ce5c881f4aeac035119925ab2c81b Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Mon, 5 Apr 2021 10:33:51 +1200 Subject: [PATCH] test(prefer-hooks-on-top): add cases for `.each` --- .../__tests__/prefer-hooks-on-top.test.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/rules/__tests__/prefer-hooks-on-top.test.ts b/src/rules/__tests__/prefer-hooks-on-top.test.ts index e5cfa4209..d7ba071be 100644 --- a/src/rules/__tests__/prefer-hooks-on-top.test.ts +++ b/src/rules/__tests__/prefer-hooks-on-top.test.ts @@ -45,6 +45,48 @@ ruleTester.run('basic describe block', rule, { }, ], }, + { + code: dedent` + describe('foo', () => { + beforeEach(() => {}); + test.each\`\`('bar', () => { + someFn(); + }); + beforeAll(() => {}); + test.only('bar', () => { + someFn(); + }); + }); + `, + errors: [ + { + messageId: 'noHookOnTop', + column: 3, + line: 6, + }, + ], + }, + { + code: dedent` + describe('foo', () => { + beforeEach(() => {}); + test.only.each\`\`('bar', () => { + someFn(); + }); + beforeAll(() => {}); + test.only('bar', () => { + someFn(); + }); + }); + `, + errors: [ + { + messageId: 'noHookOnTop', + column: 3, + line: 6, + }, + ], + }, ], });