Skip to content

Commit

Permalink
feat(rule-tester): allow to create empty tests
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Sep 3, 2023
1 parent b74b1e4 commit 7fac45e
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions packages/rule-tester/src/RuleTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,33 +395,37 @@ export class RuleTester extends TestFramework {
* one of the templates above.
*/
constructor.describe(ruleName, () => {
constructor.describe('valid', () => {
normalizedTests.valid.forEach(valid => {
const testName = ((): string => {
if (valid.name == null || valid.name.length === 0) {
return valid.code;
}
return valid.name;
})();
constructor[getTestMethod(valid)](sanitize(testName), () => {
this.#testValidTemplate(ruleName, rule, valid);
if (normalizedTests.valid.length) {
constructor.describe('valid', () => {
normalizedTests.valid.forEach(valid => {
const testName = ((): string => {
if (valid.name == null || valid.name.length === 0) {
return valid.code;
}
return valid.name;
})();
constructor[getTestMethod(valid)](sanitize(testName), () => {
this.#testValidTemplate(ruleName, rule, valid);
});
});
});
});
}

constructor.describe('invalid', () => {
normalizedTests.invalid.forEach(invalid => {
const name = ((): string => {
if (invalid.name == null || invalid.name.length === 0) {
return invalid.code;
}
return invalid.name;
})();
constructor[getTestMethod(invalid)](sanitize(name), () => {
this.#testInvalidTemplate(ruleName, rule, invalid);
if (normalizedTests.invalid.length) {
constructor.describe('invalid', () => {
normalizedTests.invalid.forEach(invalid => {
const name = ((): string => {
if (invalid.name == null || invalid.name.length === 0) {
return invalid.code;
}
return invalid.name;
})();
constructor[getTestMethod(invalid)](sanitize(name), () => {
this.#testInvalidTemplate(ruleName, rule, invalid);
});
});
});
});
}
});
}

Expand Down

0 comments on commit 7fac45e

Please sign in to comment.