Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prefer-lowercase-title): ignore it and test separately #1011

Merged
merged 1 commit into from Jan 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
115 changes: 111 additions & 4 deletions src/rules/__tests__/prefer-lowercase-title.test.ts
Expand Up @@ -270,7 +270,34 @@ ruleTester.run('prefer-lowercase-title with ignore=describe', rule, {
options: [{ ignore: [DescribeAlias.describe] }],
},
],
invalid: [],
invalid: [
{
code: "test('Foo', function () {})",
output: "test('foo', function () {})",
options: [{ ignore: [DescribeAlias.describe] }],
errors: [
{
messageId: 'unexpectedLowercase',
data: { method: TestCaseName.test },
column: 6,
line: 1,
},
],
},
{
code: "xit('Foo', function () {})",
output: "xit('foo', function () {})",
options: [{ ignore: [DescribeAlias.describe] }],
errors: [
{
messageId: 'unexpectedLowercase',
data: { method: TestCaseName.xit },
column: 5,
line: 1,
},
],
},
],
});

ruleTester.run('prefer-lowercase-title with ignore=test', rule, {
Expand All @@ -296,7 +323,47 @@ ruleTester.run('prefer-lowercase-title with ignore=test', rule, {
options: [{ ignore: [TestCaseName.test] }],
},
],
invalid: [],
invalid: [
{
code: "describe('Foo', function () {})",
output: "describe('foo', function () {})",
options: [{ ignore: [TestCaseName.test] }],
errors: [
{
messageId: 'unexpectedLowercase',
data: { method: DescribeAlias.describe },
column: 10,
line: 1,
},
],
},
{
code: "it('Foo', function () {})",
output: "it('foo', function () {})",
options: [{ ignore: [TestCaseName.test] }],
errors: [
{
messageId: 'unexpectedLowercase',
data: { method: TestCaseName.it },
column: 4,
line: 1,
},
],
},
{
code: "xit('Foo', function () {})",
output: "xit('foo', function () {})",
options: [{ ignore: [TestCaseName.test] }],
errors: [
{
messageId: 'unexpectedLowercase',
data: { method: TestCaseName.xit },
column: 5,
line: 1,
},
],
},
],
});

ruleTester.run('prefer-lowercase-title with ignore=it', rule, {
Expand All @@ -322,7 +389,47 @@ ruleTester.run('prefer-lowercase-title with ignore=it', rule, {
options: [{ ignore: [TestCaseName.it] }],
},
],
invalid: [],
invalid: [
{
code: "describe('Foo', function () {})",
output: "describe('foo', function () {})",
options: [{ ignore: [TestCaseName.it] }],
errors: [
{
messageId: 'unexpectedLowercase',
data: { method: DescribeAlias.describe },
column: 10,
line: 1,
},
],
},
{
code: "test('Foo', function () {})",
output: "test('foo', function () {})",
options: [{ ignore: [TestCaseName.it] }],
errors: [
{
messageId: 'unexpectedLowercase',
data: { method: TestCaseName.test },
column: 6,
line: 1,
},
],
},
{
code: "xtest('Foo', function () {})",
output: "xtest('foo', function () {})",
options: [{ ignore: [TestCaseName.it] }],
errors: [
{
messageId: 'unexpectedLowercase',
data: { method: TestCaseName.xtest },
column: 7,
line: 1,
},
],
},
],
});

ruleTester.run('prefer-lowercase-title with allowedPrefixes', rule, {
Expand Down Expand Up @@ -368,7 +475,7 @@ ruleTester.run('prefer-lowercase-title with ignoreTopLevelDescribe', rule, {
expect('abc').toBe('abc');
});
});

describe('Booleans', () => {
it('are booleans', () => {
expect(true).toBe(true);
Expand Down
8 changes: 6 additions & 2 deletions src/rules/prefer-lowercase-title.ts
Expand Up @@ -43,10 +43,14 @@ const populateIgnores = (ignore: readonly string[]): string[] => {
ignores.push(...Object.keys(DescribeAlias));
}
if (ignore.includes(TestCaseName.test)) {
ignores.push(...Object.keys(TestCaseName));
ignores.push(
...Object.keys(TestCaseName).filter(k => k.endsWith(TestCaseName.test)),
);
}
if (ignore.includes(TestCaseName.it)) {
ignores.push(...Object.keys(TestCaseName));
ignores.push(
...Object.keys(TestCaseName).filter(k => k.endsWith(TestCaseName.it)),
);
}

return ignores;
Expand Down