-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathusage.test.js
64 lines (58 loc) · 1.99 KB
/
usage.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const githubMarkdownLint = require("../index");
describe("usage", () => {
describe("default export", () => {
test("custom rules on default export", () => {
const rules = githubMarkdownLint;
expect(rules).toHaveLength(2);
expect(rules[0].names).toEqual(["GH001", "no-default-alt-text"]);
});
});
describe("init method", () => {
test("default options returned with no arguments provided", () => {
const options = githubMarkdownLint.init();
expect(options).toEqual({
"no-duplicate-header": true,
"ol-prefix": "ordered",
"no-space-in-links": false,
"single-h1": true,
"no-emphasis-as-header": true,
"no-generic-link-text": true,
"ul-style": true,
default: true,
"no-inline-html": false,
"no-bare-urls": false,
"no-blanks-blockquote": false,
"fenced-code-language": true,
"no-default-alt-text": true,
});
});
test("arguments override default configuration", () => {
const defaultOptions = githubMarkdownLint.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 = githubMarkdownLint.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]]
);
});
});
});