Skip to content

Commit

Permalink
test: improve tests of rule and config existence
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Aug 13, 2021
1 parent abd8a54 commit e7e5d5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions tests/configs.test.ts
Expand Up @@ -14,14 +14,17 @@ import noStatements from "~/configs/no-statements";
import stylistic from "~/configs/stylistic";
import { rules } from "~/rules";

test('Config "All" - should have all the rules', (t) => {
const allRules = Object.keys(rules);
test('Config "All" - should have all the non-deprecated rules', (t) => {
const allRules = Object.values(rules);
const allNonDeprecatedRules = allRules.filter(
(rule) => rule.meta.deprecated !== true
);

const configAllJSRules = Object.keys(all.rules ?? {});
const configAllTSRules = Object.keys(all.overrides?.[0].rules ?? {});
const configAllRules = new Set([...configAllJSRules, ...configAllTSRules]);

t.is(configAllRules.size, allRules.length);
t.is(configAllRules.size, allNonDeprecatedRules.length);
});

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/index.test.ts
Expand Up @@ -20,13 +20,13 @@ test("should have all the rules", (t) => {
Object.prototype.hasOwnProperty.call(plugin, "rules"),
'The plugin\'s config object should have a "rules" property.'
);
t.assert(Object.keys(plugin.rules).length === ruleFiles.length);
t.is(ruleFiles.length, Object.keys(plugin.rules).length);
});

test("should have all the configs", (t) => {
t.true(
Object.prototype.hasOwnProperty.call(plugin, "configs"),
'The plugin\'s config object should have a "configs" property.'
);
t.assert(Object.keys(plugin.configs).length === configFiles.length);
t.is(configFiles.length, Object.keys(plugin.configs).length);
});

0 comments on commit e7e5d5b

Please sign in to comment.