Skip to content

Commit

Permalink
fix(no-identical-titles): support nested describes (#790)
Browse files Browse the repository at this point in the history
  • Loading branch information
idan-at authored Mar 10, 2021
1 parent e5561d6 commit ce26621
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/rules/__tests__/no-identical-title.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ ruleTester.run('no-identical-title', rule, {
${'a'}
\`("$description", () => {})
`,
dedent`
describe("top level", () => {
describe.each\`\`("nested each", () => {
describe.each\`\`("nested nested each", () => {})
})
describe("nested", () => {})
})
`,
],
invalid: [
{
Expand Down
7 changes: 4 additions & 3 deletions src/rules/no-identical-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ export default createRule({
CallExpression(node) {
const currentLayer = contexts[contexts.length - 1];

if (isDescribe(node)) {
contexts.push(newDescribeContext());
}

if (node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression) {
return;
}

if (isDescribe(node)) {
contexts.push(newDescribeContext());
}
const [argument] = node.arguments;

if (!argument || !isStringNode(argument)) {
Expand Down

0 comments on commit ce26621

Please sign in to comment.