import { expect, test } from "bun:test"; import PostCSS from "../postcss"; // Dummy PostCSS plugin that uppercases all CSS function uppercasePlugin() { return { postcssPlugin: "uppercase", Once(root: any) { root.walkDecls((decl: any) => { decl.value = decl.value.toUpperCase(); decl.prop = decl.prop.toUpperCase(); }); } }; } uppercasePlugin.postcss = true; test("PostCSS applies plugins to CSS", async () => { const plugin = new PostCSS([uppercasePlugin()]); const input = "body { color: red; }"; const output = await plugin.rewriteFile(input); expect(output).toContain("COLOR: RED;"); }); test("PostCSS returns unchanged CSS if no plugins", async () => { const plugin = new PostCSS([]); const input = "body { color: blue; }"; const output = await plugin.rewriteFile(input); expect(output).toBe(input); }); test("PostCSS handles multiple plugins", async () => { // Plugin to replace 'red' with 'green' function replaceRedPlugin() { return { postcssPlugin: "replace-red", Once(root: any) { root.walkDecls((decl: any) => { decl.value = decl.value.replace(/red/g, "green"); }); } }; } replaceRedPlugin.postcss = true; const plugin = new PostCSS([replaceRedPlugin(), uppercasePlugin()]); const input = "body { color: red; }"; const output = await plugin.rewriteFile(input); expect(output).toContain("COLOR: GREEN;"); });