-
-
Notifications
You must be signed in to change notification settings - Fork 199
Expand file tree
/
Copy pathimplementation.test.js
More file actions
62 lines (54 loc) · 2.03 KB
/
Copy pathimplementation.test.js
File metadata and controls
62 lines (54 loc) · 2.03 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
import {
compile,
getCodeFromBundle,
getCodeFromLess,
getCompiler,
getErrors,
getWarnings,
} from "./helpers";
describe('"implementation" option', () => {
it("should work", async () => {
const testId = "./basic.less";
const compiler = getCompiler(testId, {
implementation: require("less"),
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle(stats, compiler);
const codeFromLess = await getCodeFromLess(testId);
expect(codeFromBundle.css).toBe(codeFromLess.css);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it("should work when implementation option is string", async () => {
const testId = "./basic.less";
const compiler = getCompiler(testId, {
implementation: require.resolve("less"),
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle(stats, compiler);
const codeFromLess = await getCodeFromLess(testId);
expect(codeFromBundle.css).toBe(codeFromLess.css);
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it("should throw error when unresolved package", async () => {
const testId = "./basic.less";
const compiler = getCompiler(testId, {
implementation: "unresolved",
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
it("should throw error when implementation has error", async () => {
const testId = "./basic.less";
const compiler = getCompiler(testId, {
implementation: require.resolve("./fixtures/implementation-error.js"),
});
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});