This commit is contained in:
Alex
2024-07-06 19:17:37 -04:00
parent a05b1222b5
commit 53ac883c18
14 changed files with 259 additions and 200 deletions

View File

@ -1,6 +1,5 @@
import { describe, expect, it } from "vitest";
import { getClassName } from "../index";
import { getBuild } from "./utils";
import { describe, it } from "vitest";
import { getBuild, matchSnapshot } from "./utils";
describe("babel-tailwind", () => {
const compileESBuild = getBuild("tw");
@ -25,31 +24,7 @@ describe("babel-tailwind", () => {
`,
});
const clsName = getClassName(
"text-sm flex group-hover:text-center [&>div]:font-semibold data-[name='hello']:text-right data-[nested=true]:border"
);
expect(files.js.text).toContain(`= "${clsName}"`);
expect(files.css.text).toMatch(
[
`.${clsName} {`,
" display: flex;",
" font-size: 0.875rem;",
" line-height: 1.25rem;",
"}",
`.group:hover .${clsName} {`,
" text-align: center;",
"}",
`.${clsName}[data-nested=true] {`,
" border-width: 1px;",
"}",
`.${clsName}[data-name=hello] {`,
" text-align: right;",
"}",
`.${clsName} > div {`,
" font-weight: 600;",
"}",
].join("\n")
);
matchSnapshot(files);
});
it("passes through `group` className", async () => {
@ -63,10 +38,6 @@ describe("babel-tailwind", () => {
`,
});
const clsName = getClassName("group hover:text-center");
expect(files.js.text).toContain(`"${clsName} group"`);
expect(files.css.text).toMatch(
[`.${clsName}:hover {`, " text-align: center;", "}"].join("\n")
);
matchSnapshot(files);
});
});