-
Notifications
You must be signed in to change notification settings - Fork 16
/
plugin.test.js
43 lines (32 loc) · 1.18 KB
/
plugin.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const { readdir } = require("fs/promises");
const { join } = require("path");
const plugin = require("./index");
const { createLinkToRule } = require("./utils/create-link-to-rule");
describe("plugin", () => {
test("any rule should have a link to docs", () => {
const { rules } = plugin;
Object.entries(rules).forEach(([name, rule]) => {
expect(rule.meta.docs.url).toBe(createLinkToRule(name));
});
});
test("any rule should be exported", async () => {
const rulesDirContent = await readdir(join(__dirname, "rules"));
const allRules = rulesDirContent
.filter((fileName) => !fileName.includes(".json"))
.sort();
const exportedRules = Object.entries(plugin.rules)
.map(([name]) => name)
.sort();
expect(exportedRules).toEqual(allRules);
});
test("any config should be exported", async () => {
const configsDirContent = await readdir(join(__dirname, "config"));
const allConfigs = configsDirContent
.map((fileName) => fileName.replace(".js", ""))
.sort();
const exportedConfigs = Object.entries(plugin.configs)
.map(([name]) => name)
.sort();
expect(exportedConfigs).toEqual(allConfigs);
});
});