Skip to content

Commit

Permalink
fix(jest/no-identical-title): don't show an error for different templ…
Browse files Browse the repository at this point in the history
…ate literals (#239)
  • Loading branch information
ronami authored and SimenB committed Mar 12, 2019
1 parent 4f8ef6d commit f6f6d84
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions rules/__tests__/no-identical-title.test.js
Expand Up @@ -94,6 +94,21 @@ ruleTester.run('no-identical-title', rule, {
es6: true,
},
},
{
code: ['it(`it1`, () => {});', 'it(`it2`, () => {});'].join('\n'),
env: {
es6: true,
},
},
{
code: [
'describe(`describe1`, () => {});',
'describe(`describe2`, () => {});',
].join('\n'),
env: {
es6: true,
},
},
],

invalid: [
Expand Down
10 changes: 9 additions & 1 deletion rules/no-identical-title.js
Expand Up @@ -50,6 +50,14 @@ const isFirstArgValid = arg => {
return true;
};

const getArgValue = arg => {
if (arg.type === 'TemplateLiteral') {
return arg.quasis[0].value.raw;
}

return arg.value;
};

module.exports = {
meta: {
docs: {
Expand All @@ -68,7 +76,7 @@ module.exports = {
if (!isFirstArgValid(firstArgument)) {
return;
}
const title = node.arguments[0].value;
const title = getArgValue(firstArgument);
handleTestCaseTitles(context, currentLayer.testTitles, node, title);
handleDescribeBlockTitles(
context,
Expand Down

0 comments on commit f6f6d84

Please sign in to comment.