Skip to content

Commit

Permalink
fix(rules): improve no-identical-title error message (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranyitz authored and SimenB committed Apr 19, 2018
1 parent 03a7cda commit 8213ada
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
27 changes: 18 additions & 9 deletions rules/__tests__/no-identical-title.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ ruleTester.run('no-identical-title', rule, {
].join('\n'),
errors: [
{
message: 'Test title is used multiple times in the same test suite.',
message:
'Test title is used multiple times in the same describe block.',
column: 4,
line: 3,
},
Expand All @@ -105,7 +106,8 @@ ruleTester.run('no-identical-title', rule, {
),
errors: [
{
message: 'Test title is used multiple times in the same test suite.',
message:
'Test title is used multiple times in the same describe block.',
column: 1,
line: 2,
},
Expand All @@ -118,7 +120,8 @@ ruleTester.run('no-identical-title', rule, {
].join('\n'),
errors: [
{
message: 'Test title is used multiple times in the same test suite.',
message:
'Test title is used multiple times in the same describe block.',
column: 1,
line: 2,
},
Expand All @@ -130,7 +133,8 @@ ruleTester.run('no-identical-title', rule, {
),
errors: [
{
message: 'Test title is used multiple times in the same test suite.',
message:
'Test title is used multiple times in the same describe block.',
column: 1,
line: 2,
},
Expand All @@ -143,7 +147,8 @@ ruleTester.run('no-identical-title', rule, {
].join('\n'),
errors: [
{
message: 'Test title is used multiple times in the same test suite.',
message:
'Test title is used multiple times in the same describe block.',
column: 1,
line: 2,
},
Expand All @@ -156,7 +161,8 @@ ruleTester.run('no-identical-title', rule, {
].join('\n'),
errors: [
{
message: 'Test suite title is used multiple times.',
message:
'Describe block title is used multiple times in the same describe block.',
column: 1,
line: 2,
},
Expand All @@ -169,7 +175,8 @@ ruleTester.run('no-identical-title', rule, {
].join('\n'),
errors: [
{
message: 'Test suite title is used multiple times.',
message:
'Describe block title is used multiple times in the same describe block.',
column: 1,
line: 2,
},
Expand All @@ -182,7 +189,8 @@ ruleTester.run('no-identical-title', rule, {
].join('\n'),
errors: [
{
message: 'Test suite title is used multiple times.',
message:
'Describe block title is used multiple times in the same describe block.',
column: 1,
line: 2,
},
Expand All @@ -197,7 +205,8 @@ ruleTester.run('no-identical-title', rule, {
].join('\n'),
errors: [
{
message: 'Test suite title is used multiple times.',
message:
'Describe block title is used multiple times in the same describe block.',
column: 1,
line: 4,
},
Expand Down
10 changes: 6 additions & 4 deletions rules/no-identical-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ const handleTestCaseTitles = (context, titles, node, title) => {
if (isTestCase(node)) {
if (titles.indexOf(title) !== -1) {
context.report({
message: 'Test title is used multiple times in the same test suite.',
message:
'Test title is used multiple times in the same describe block.',
node,
});
}
titles.push(title);
}
};

const handleTestSuiteTitles = (context, titles, node, title) => {
const handleDescribeBlockTitles = (context, titles, node, title) => {
if (!isDescribe(node)) {
return;
}
if (titles.indexOf(title) !== -1) {
context.report({
message: 'Test suite title is used multiple times.',
message:
'Describe block title is used multiple times in the same describe block.',
node,
});
}
Expand Down Expand Up @@ -57,7 +59,7 @@ module.exports = {

const title = node.arguments[0].value;
handleTestCaseTitles(context, currentLayer.testTitles, node, title);
handleTestSuiteTitles(
handleDescribeBlockTitles(
context,
currentLayer.describeTitles,
node,
Expand Down

0 comments on commit 8213ada

Please sign in to comment.