Bug fixes
This commit is contained in:
@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { getBuild } from "./utils";
|
||||
import { getClassName } from "../index";
|
||||
|
||||
describe.only("babel-tailwind", () => {
|
||||
describe("babel-tailwind", () => {
|
||||
const compileESBuild = getBuild("styleObject");
|
||||
|
||||
it("supports conversion into CSSProperties", async () => {
|
||||
@ -10,9 +10,11 @@ describe.only("babel-tailwind", () => {
|
||||
clsx: "emotion",
|
||||
expectFiles: 1,
|
||||
javascript: `
|
||||
import { tws } from "@aet/tailwind/macro";
|
||||
|
||||
export function Hello() {
|
||||
return (
|
||||
<div style={tws\`p-2 text-center\`}>
|
||||
<div style={tws\`p-2 text-center hover:font-semibold sm:p-1\`}>
|
||||
Hello, world!
|
||||
</div>
|
||||
);
|
||||
@ -20,9 +22,23 @@ describe.only("babel-tailwind", () => {
|
||||
`,
|
||||
});
|
||||
|
||||
const clsName = getClassName("p-2 text-center").replace(/^tw-/, "tw_");
|
||||
const clsName = getClassName("p-2 text-center hover:font-semibold sm:p-1").replace(
|
||||
/^tw-/,
|
||||
"tw_"
|
||||
);
|
||||
expect(files.js.text).toContain(
|
||||
`var ${clsName} = {\n "padding": "0.5rem",\n "textAlign": "center"\n}`
|
||||
[
|
||||
`var ${clsName} = {`,
|
||||
' padding: "0.5rem",',
|
||||
' textAlign: "center",',
|
||||
' "&:hover": {',
|
||||
' fontWeight: "600"',
|
||||
" },",
|
||||
' "@media (min-width: 640px)": {',
|
||||
' padding: "0.25rem"',
|
||||
" }",
|
||||
"}",
|
||||
].join("\n")
|
||||
);
|
||||
expect(files.js.text).toContain(`style: ${clsName}`);
|
||||
});
|
||||
|
@ -4,11 +4,14 @@ import { getBuild } from "./utils";
|
||||
|
||||
describe("babel-tailwind", () => {
|
||||
const compileESBuild = getBuild("tw");
|
||||
|
||||
it("supports grouped tw", async () => {
|
||||
const { files } = await compileESBuild({
|
||||
clsx: "emotion",
|
||||
expectFiles: 2,
|
||||
javascript: `
|
||||
import { tw } from "@aet/tailwind/macro";
|
||||
|
||||
export default tw("text-sm", \`flex\`, {
|
||||
"group-hover": "text-center",
|
||||
"[&>div]": \`font-semibold\`,
|
||||
|
Reference in New Issue
Block a user