-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod_test.ts
47 lines (43 loc) · 1.35 KB
/
mod_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
import { assertStringIncludes } from "https://deno.land/std@0.97.0/testing/asserts.ts";
import { generate, init } from "./mod.ts";
const config = { mode: "silent" } as const;
const info = init(config);
Deno.test("integration test", async () => {
const styles = await generate(
[`<body class="bg-purple-500"></body>`],
info,
);
assertStringIncludes(
styles,
".bg-purple-500",
);
});
Deno.test("integration test 2", async () => {
const styles = await generate([
`<body class="bg-purple-500"></body>`,
`<body class="bg-purple-600"></body>`,
`bg-blue-700`, // raw class name works
`< asdf foobar="bg-red-800"> bg-gray-900`, // broken html doesn't matter
], info);
assertStringIncludes(styles, ".bg-purple-500");
assertStringIncludes(styles, ".bg-purple-600");
assertStringIncludes(styles, ".bg-blue-700");
assertStringIncludes(styles, ".bg-red-800");
assertStringIncludes(styles, ".bg-gray-900");
});
Deno.test("exception words", () => {
// This test case checks that special words which has problem with twind
// don't throw.
// See https://github.com/tw-in-js/twind/issues/189 for details.
generate([
"__defineGetter__",
"__defineSetter__",
"__lookupGetter__",
"__lookupSetter__",
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable",
"toLocaleString",
"valueOf",
], info);
});