diff --git a/src/rules/__tests__/lowercase-name.test.ts b/src/rules/__tests__/lowercase-name.test.ts index 271361d9a..a68d6b75f 100644 --- a/src/rules/__tests__/lowercase-name.test.ts +++ b/src/rules/__tests__/lowercase-name.test.ts @@ -76,6 +76,18 @@ ruleTester.run('lowercase-name', rule, { }, ], }, + { + code: "xit('Foo', function () {})", + output: "xit('foo', function () {})", + errors: [ + { + messageId: 'unexpectedLowercase', + data: { method: TestCaseName.xit }, + column: 5, + line: 1, + }, + ], + }, { code: 'it("Foo", function () {})', output: 'it("foo", function () {})', @@ -112,6 +124,18 @@ ruleTester.run('lowercase-name', rule, { }, ], }, + { + code: "xtest('Foo', function () {})", + output: "xtest('foo', function () {})", + errors: [ + { + messageId: 'unexpectedLowercase', + data: { method: TestCaseName.xtest }, + column: 7, + line: 1, + }, + ], + }, { code: 'test("Foo", function () {})', output: 'test("foo", function () {})', @@ -184,6 +208,18 @@ ruleTester.run('lowercase-name', rule, { }, ], }, + { + code: 'fdescribe(`Some longer description`, function () {})', + output: 'fdescribe(`some longer description`, function () {})', + errors: [ + { + messageId: 'unexpectedLowercase', + data: { method: DescribeAlias.fdescribe }, + column: 11, + line: 1, + }, + ], + }, { code: "it.each(['green', 'black'])('Should return %', () => {})", output: "it.each(['green', 'black'])('should return %', () => {})", @@ -225,6 +261,14 @@ ruleTester.run('lowercase-name with ignore=describe', rule, { code: 'describe(`Foo`, function () {})', options: [{ ignore: [DescribeAlias.describe] }], }, + { + code: 'fdescribe(`Foo`, function () {})', + options: [{ ignore: [DescribeAlias.describe] }], + }, + { + code: 'describe.skip(`Foo`, function () {})', + options: [{ ignore: [DescribeAlias.describe] }], + }, ], invalid: [], }); @@ -243,6 +287,14 @@ ruleTester.run('lowercase-name with ignore=test', rule, { code: 'test(`Foo`, function () {})', options: [{ ignore: [TestCaseName.test] }], }, + { + code: 'xtest(`Foo`, function () {})', + options: [{ ignore: [TestCaseName.test] }], + }, + { + code: 'test.only(`Foo`, function () {})', + options: [{ ignore: [TestCaseName.test] }], + }, ], invalid: [], }); @@ -261,6 +313,14 @@ ruleTester.run('lowercase-name with ignore=it', rule, { code: 'it(`Foo`, function () {})', options: [{ ignore: [TestCaseName.it] }], }, + { + code: 'fit(`Foo`, function () {})', + options: [{ ignore: [TestCaseName.it] }], + }, + { + code: 'it.skip(`Foo`, function () {})', + options: [{ ignore: [TestCaseName.it] }], + }, ], invalid: [], }); diff --git a/src/rules/lowercase-name.ts b/src/rules/lowercase-name.ts index 8b67cfa59..f0b9571f1 100644 --- a/src/rules/lowercase-name.ts +++ b/src/rules/lowercase-name.ts @@ -36,6 +36,22 @@ const findNodeNameAndArgument = ( return [getNodeName(node).split('.')[0], node.arguments[0]]; }; +const populateIgnores = (ignore: readonly string[]): string[] => { + const ignores: string[] = []; + + if (ignore.includes(DescribeAlias.describe)) { + ignores.push(...Object.keys(DescribeAlias)); + } + if (ignore.includes(TestCaseName.test)) { + ignores.push(...Object.keys(TestCaseName)); + } + if (ignore.includes(TestCaseName.it)) { + ignores.push(...Object.keys(TestCaseName)); + } + + return ignores; +}; + export default createRule< [ Partial<{ @@ -94,6 +110,7 @@ export default createRule< context, [{ ignore = [], allowedPrefixes = [], ignoreTopLevelDescribe }], ) { + const ignores = populateIgnores(ignore); let numberOfDescribeBlocks = 0; return { @@ -125,7 +142,7 @@ export default createRule< if ( !firstCharacter || firstCharacter === firstCharacter.toLowerCase() || - ignore.includes(name as IgnorableFunctionExpressions) + ignores.includes(name as IgnorableFunctionExpressions) ) { return; }