Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/rules/__tests__/no-identical-title.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@ ruleTester.run('no-identical-title', rule, {
es6: true,
},
},
{
code: [
'const test = { content: () => "foo" }',
'test.content(`testing backticks with the same title`);',
'test.content(`testing backticks with the same title`);',
].join('\n'),
env: {
es6: true,
},
},
{
code: [
'const describe = { content: () => "foo" }',
'describe.content(`testing backticks with the same title`);',
'describe.content(`testing backticks with the same title`);',
].join('\n'),
env: {
es6: true,
},
},
],

invalid: [
Expand Down
10 changes: 8 additions & 2 deletions src/rules/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ const describeAliases = new Set(['describe', 'fdescribe', 'xdescribe']);

const testCaseNames = new Set(['fit', 'it', 'test', 'xit', 'xtest']);

const describeProperties = new Set(['each', 'only', 'skip']);

const testCaseProperties = new Set(['each', 'only', 'skip', 'todo']);

export const isTestCase = node =>
node &&
node.type === 'CallExpression' &&
((node.callee.type === 'Identifier' && testCaseNames.has(node.callee.name)) ||
(node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
testCaseNames.has(node.callee.object.name)));
testCaseNames.has(node.callee.object.name) &&
testCaseProperties.has(node.callee.property.name)));

export const isDescribe = node =>
node &&
Expand All @@ -116,7 +121,8 @@ export const isDescribe = node =>
describeAliases.has(node.callee.name)) ||
(node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
describeAliases.has(node.callee.object.name)));
describeAliases.has(node.callee.object.name) &&
describeProperties.has(node.callee.property.name)));

export const isFunction = node =>
node &&
Expand Down