-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathusage.test.js
More file actions
73 lines (66 loc) · 2.29 KB
/
usage.test.js
File metadata and controls
73 lines (66 loc) · 2.29 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { init } from "../index.js";
import { githubMarkdownLint } from "../src/rules/index.js";
describe("usage", () => {
describe("default export", () => {
test("custom rules on default export", () => {
const rules = githubMarkdownLint;
expect(rules).toHaveLength(3);
expect(rules[0].names).toEqual(["GH001", "no-default-alt-text"]);
expect(rules[1].names).toEqual(["GH002", "no-generic-link-text"]);
expect(rules[2].names).toEqual(["GH003", "no-empty-alt-text"]);
});
});
describe("init method", () => {
test("default options returned with no arguments provided", async () => {
const options = await init();
expect(options).toEqual({
"no-duplicate-heading": true,
"ol-prefix": "ordered",
"no-space-in-links": false,
"single-h1": true,
"no-emphasis-as-heading": true,
"no-empty-alt-text": false,
"heading-increment": true,
"no-generic-link-text": true,
"ul-style": {
style: "asterisk",
},
default: true,
"no-inline-html": false,
"no-bare-urls": false,
"no-blanks-blockquote": false,
"fenced-code-language": true,
"no-default-alt-text": true,
"no-alt-text": true,
});
});
test("arguments override default configuration", async () => {
const defaultOptions = await init();
const toTestOptions = Object.keys(defaultOptions).slice(0, 3);
// create a consumer config that is the opposite of the default config
const originalConfig = {};
const consumerConfig = {};
for (const key of toTestOptions) {
consumerConfig[key] = !defaultOptions[key];
originalConfig[key] = defaultOptions[key];
}
// confirm they are not the same
expect(originalConfig).not.toEqual(consumerConfig);
// do config step
const options = await init(consumerConfig);
// confirm config is set by consumer
expect(options).toHaveProperty(
toTestOptions[0],
consumerConfig[toTestOptions[0]],
);
expect(options).toHaveProperty(
toTestOptions[1],
consumerConfig[toTestOptions[1]],
);
expect(options).toHaveProperty(
toTestOptions[2],
consumerConfig[toTestOptions[2]],
);
});
});
});