Skip to content

Commit

Permalink
test: allow any description for jest.each
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Feb 19, 2020
1 parent 74c53c8 commit eff9d58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
12 changes: 7 additions & 5 deletions tslint-rules/dist/meaningfulNamingInTestsRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ var Rule = (function (_super) {
if (description.indexOf('${') >= 0) {
description = descriptionToken.parent.getText();
}
if (DESCRIPTION_VIEWPOINT_ERROR_REGEX.test(description)) {
ctx.addFailureAtNode(descriptionToken, "describe what the component is doing, not what the test is doing (found \"" + description + "\")");
}
else if (!DESCRIPTION_REGEX.test(description)) {
ctx.addFailureAtNode(descriptionToken, "\"" + description + "\" does not match " + DESCRIPTION_REGEX);
if (description !== 'each') {
if (DESCRIPTION_VIEWPOINT_ERROR_REGEX.test(description)) {
ctx.addFailureAtNode(descriptionToken, "describe what the component is doing, not what the test is doing (found \"" + description + "\")");
}
else if (!DESCRIPTION_REGEX.test(description)) {
ctx.addFailureAtNode(descriptionToken, "\"" + description + "\" does not match " + DESCRIPTION_REGEX);
}
}
}
else {
Expand Down
17 changes: 10 additions & 7 deletions tslint-rules/src/meaningfulNamingInTestsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ export class Rule extends Lint.Rules.AbstractRule {
if (description.indexOf('${') >= 0) {
description = descriptionToken.parent.getText();
}
if (DESCRIPTION_VIEWPOINT_ERROR_REGEX.test(description)) {
ctx.addFailureAtNode(
descriptionToken,
`describe what the component is doing, not what the test is doing (found "${description}")`
);
} else if (!DESCRIPTION_REGEX.test(description)) {
ctx.addFailureAtNode(descriptionToken, `"${description}" does not match ${DESCRIPTION_REGEX}`);
// allow everything for jest.each
if (description !== 'each') {
if (DESCRIPTION_VIEWPOINT_ERROR_REGEX.test(description)) {
ctx.addFailureAtNode(
descriptionToken,
`describe what the component is doing, not what the test is doing (found "${description}")`
);
} else if (!DESCRIPTION_REGEX.test(description)) {
ctx.addFailureAtNode(descriptionToken, `"${description}" does not match ${DESCRIPTION_REGEX}`);
}
}
} else {
ctx.addFailureAtNode(node, 'could not find a valid description');
Expand Down

0 comments on commit eff9d58

Please sign in to comment.