/
printConfig.test.js
64 lines (58 loc) · 1.53 KB
/
printConfig.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
"use strict";
const path = require("path");
const pluginWarnAboutFoo = require("./fixtures/plugin-warn-about-foo");
const printConfig = require("../printConfig");
it("printConfig uses getConfigForFile to retrieve the config", () => {
const filepath = path.join(
__dirname,
"fixtures/getConfigForFile/a/b/foo.css"
);
printConfig({
files: [filepath]
}).then(result => {
expect(result).toEqual({
plugins: [path.join(__dirname, "/fixtures/plugin-warn-about-foo.js")],
rules: {
"block-no-empty": [true],
"plugin/warn-about-foo": ["always"]
},
pluginFunctions: {
"plugin/warn-about-foo": pluginWarnAboutFoo.rule
}
});
});
});
it("printConfig with input css should throw", () => {
expect(
printConfig({
code: "a {}"
})
).rejects.toThrow(
"The --print-config option must be used with exactly one file path."
);
});
it("printConfig with no path should throw", () => {
expect(
printConfig({
files: []
})
).rejects.toThrow(
"The --print-config option must be used with exactly one file path."
);
});
it("printConfig with multiple paths should throw", () => {
expect(
printConfig({
files: ["./first-path.css", "./second-path.css"]
})
).rejects.toThrow(
"The --print-config option must be used with exactly one file path."
);
});
it("printConfig with globs should throw", () => {
expect(
printConfig({
files: ["./*.css"]
})
).rejects.toThrow("The --print-config option does not support globs.");
});