-
Notifications
You must be signed in to change notification settings - Fork 0
/
stylus.test.ts
71 lines (67 loc) · 1.72 KB
/
stylus.test.ts
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
import {
assertEquals,
assertGreaterOrEqual,
assertObjectMatch,
} from "@std/assert";
import * as path from "@std/path";
import { describe, it } from "@std/testing/bdd";
import { stylusPreprocessor } from "./stylus.ts";
import { build } from "./test-utils.ts";
describe("stylus", () => {
const rootDir = path.resolve("./examples/stylus");
it("stylus entrypoint should output the css", async () => {
const result = await build(
"stylus",
["./main.styl"],
{
pluginOptions: {
preprocessors: [stylusPreprocessor()],
},
},
);
assertObjectMatch(result, {
errors: [],
warnings: [],
});
assertGreaterOrEqual(result.outputFiles.length, 1);
const outFilePath = path.resolve(rootDir, "out/main.css");
assertEquals(
result.outputFiles[0].path,
outFilePath,
);
assertEquals(
result.outputFiles[0].text,
await Deno.readTextFile(outFilePath),
);
assertEquals(result.outputFiles.length, 1);
});
it("ts entrypoint should output the css to js", async () => {
const result = await build(
"stylus",
["./main.ts"],
{
pluginOptions: {
preprocessors: [stylusPreprocessor()],
},
esbuildOptions: {
bundle: true,
},
},
);
assertObjectMatch(result, {
errors: [],
warnings: [],
});
assertGreaterOrEqual(result.outputFiles.length, 1);
const outFilePath = path.resolve(rootDir, "out/main.js");
assertEquals(
result.outputFiles[0].path,
outFilePath,
);
assertEquals(
result.outputFiles[0].text,
await Deno.readTextFile(outFilePath),
);
assertEquals(result.outputFiles.length, 1);
});
});