Skip to content

Commit f1a7674

Browse files
authored
fix(prefer-lowercase-title): ignore it and test separately (#1011)
1 parent 88c43dd commit f1a7674

File tree

2 files changed

+117
-6
lines changed

2 files changed

+117
-6
lines changed

src/rules/__tests__/prefer-lowercase-title.test.ts

+111-4
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,34 @@ ruleTester.run('prefer-lowercase-title with ignore=describe', rule, {
270270
options: [{ ignore: [DescribeAlias.describe] }],
271271
},
272272
],
273-
invalid: [],
273+
invalid: [
274+
{
275+
code: "test('Foo', function () {})",
276+
output: "test('foo', function () {})",
277+
options: [{ ignore: [DescribeAlias.describe] }],
278+
errors: [
279+
{
280+
messageId: 'unexpectedLowercase',
281+
data: { method: TestCaseName.test },
282+
column: 6,
283+
line: 1,
284+
},
285+
],
286+
},
287+
{
288+
code: "xit('Foo', function () {})",
289+
output: "xit('foo', function () {})",
290+
options: [{ ignore: [DescribeAlias.describe] }],
291+
errors: [
292+
{
293+
messageId: 'unexpectedLowercase',
294+
data: { method: TestCaseName.xit },
295+
column: 5,
296+
line: 1,
297+
},
298+
],
299+
},
300+
],
274301
});
275302

276303
ruleTester.run('prefer-lowercase-title with ignore=test', rule, {
@@ -296,7 +323,47 @@ ruleTester.run('prefer-lowercase-title with ignore=test', rule, {
296323
options: [{ ignore: [TestCaseName.test] }],
297324
},
298325
],
299-
invalid: [],
326+
invalid: [
327+
{
328+
code: "describe('Foo', function () {})",
329+
output: "describe('foo', function () {})",
330+
options: [{ ignore: [TestCaseName.test] }],
331+
errors: [
332+
{
333+
messageId: 'unexpectedLowercase',
334+
data: { method: DescribeAlias.describe },
335+
column: 10,
336+
line: 1,
337+
},
338+
],
339+
},
340+
{
341+
code: "it('Foo', function () {})",
342+
output: "it('foo', function () {})",
343+
options: [{ ignore: [TestCaseName.test] }],
344+
errors: [
345+
{
346+
messageId: 'unexpectedLowercase',
347+
data: { method: TestCaseName.it },
348+
column: 4,
349+
line: 1,
350+
},
351+
],
352+
},
353+
{
354+
code: "xit('Foo', function () {})",
355+
output: "xit('foo', function () {})",
356+
options: [{ ignore: [TestCaseName.test] }],
357+
errors: [
358+
{
359+
messageId: 'unexpectedLowercase',
360+
data: { method: TestCaseName.xit },
361+
column: 5,
362+
line: 1,
363+
},
364+
],
365+
},
366+
],
300367
});
301368

302369
ruleTester.run('prefer-lowercase-title with ignore=it', rule, {
@@ -322,7 +389,47 @@ ruleTester.run('prefer-lowercase-title with ignore=it', rule, {
322389
options: [{ ignore: [TestCaseName.it] }],
323390
},
324391
],
325-
invalid: [],
392+
invalid: [
393+
{
394+
code: "describe('Foo', function () {})",
395+
output: "describe('foo', function () {})",
396+
options: [{ ignore: [TestCaseName.it] }],
397+
errors: [
398+
{
399+
messageId: 'unexpectedLowercase',
400+
data: { method: DescribeAlias.describe },
401+
column: 10,
402+
line: 1,
403+
},
404+
],
405+
},
406+
{
407+
code: "test('Foo', function () {})",
408+
output: "test('foo', function () {})",
409+
options: [{ ignore: [TestCaseName.it] }],
410+
errors: [
411+
{
412+
messageId: 'unexpectedLowercase',
413+
data: { method: TestCaseName.test },
414+
column: 6,
415+
line: 1,
416+
},
417+
],
418+
},
419+
{
420+
code: "xtest('Foo', function () {})",
421+
output: "xtest('foo', function () {})",
422+
options: [{ ignore: [TestCaseName.it] }],
423+
errors: [
424+
{
425+
messageId: 'unexpectedLowercase',
426+
data: { method: TestCaseName.xtest },
427+
column: 7,
428+
line: 1,
429+
},
430+
],
431+
},
432+
],
326433
});
327434

328435
ruleTester.run('prefer-lowercase-title with allowedPrefixes', rule, {
@@ -368,7 +475,7 @@ ruleTester.run('prefer-lowercase-title with ignoreTopLevelDescribe', rule, {
368475
expect('abc').toBe('abc');
369476
});
370477
});
371-
478+
372479
describe('Booleans', () => {
373480
it('are booleans', () => {
374481
expect(true).toBe(true);

src/rules/prefer-lowercase-title.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ const populateIgnores = (ignore: readonly string[]): string[] => {
4343
ignores.push(...Object.keys(DescribeAlias));
4444
}
4545
if (ignore.includes(TestCaseName.test)) {
46-
ignores.push(...Object.keys(TestCaseName));
46+
ignores.push(
47+
...Object.keys(TestCaseName).filter(k => k.endsWith(TestCaseName.test)),
48+
);
4749
}
4850
if (ignore.includes(TestCaseName.it)) {
49-
ignores.push(...Object.keys(TestCaseName));
51+
ignores.push(
52+
...Object.keys(TestCaseName).filter(k => k.endsWith(TestCaseName.it)),
53+
);
5054
}
5155

5256
return ignores;

0 commit comments

Comments
 (0)