-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsigui.spec.ts
68 lines (58 loc) · 1.81 KB
/
sigui.spec.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
import path from "node:path";
import postcss from "postcss";
import tailwindcss, { type Config } from "tailwindcss";
import resolveConfig from "tailwindcss/resolveConfig";
import tailwindConfig from "../tailwind.config";
import { describe, expect, it } from "vitest";
const html = String.raw;
const css = String.raw;
function run(
config: Config,
input = "@tailwind base;@tailwind components;@tailwind utilities",
plugin = tailwindcss,
) {
const { currentTestName } = expect.getState();
const fullConfig = resolveConfig({
presets: [tailwindConfig],
corePlugins: { preflight: false },
...config,
});
return postcss(plugin(fullConfig)).process(input, {
from: `${path.resolve(__filename)}?test=${currentTestName}`,
});
}
describe.concurrent("suite", () => {
const config = {
content: [
{
raw: html`<div class="text-red bg-red-xs border-red-xl"><a href="#" class="button-blue">Click button</a><a href="#" class="link">Click link</a></div>`,
},
],
};
it("should have red text class", async () => {
return run(config).then((result) => {
console.log(result.css);
expect(result.css).toContain(css`.text-red`);
});
});
it("should have bg-red-xs class", async () => {
return run(config).then((result) => {
expect(result.css).toContain(css`.bg-red-xs`);
});
});
it("should have border-red-xl class", async () => {
return run(config).then((result) => {
expect(result.css).toContain(css`.border-red-xl`);
});
});
it("should have button-blue class", async () => {
return run(config).then((result) => {
expect(result.css).toContain(css`.button-blue`);
});
});
it("should have link class", async () => {
return run(config).then((result) => {
expect(result.css).toContain(css`.link`);
});
});
});