diff --git a/tests/buttons.test.ts b/tests/buttons.test.ts index d2d2c34..7eb470b 100644 --- a/tests/buttons.test.ts +++ b/tests/buttons.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { readFileSync } from "node:fs"; +import { existsSync, readdirSync, readFileSync } from "node:fs"; import path from "node:path"; import { createElement } from "react"; import { renderToStaticMarkup } from "react-dom/server"; @@ -34,11 +34,21 @@ describe("SparkleButton disabled", () => { expect(body).toContain("var(--tile-3)"); expect(body).toContain("var(--ink-2)"); expect(body).toContain("not-allowed"); - expect(readFileSync(path.resolve(__dirname, "../src/styles/legacy.css"), "utf8")).not.toMatch(/button:disabled\s*\{[^}]*opacity/); + for (const f of readdirSync(path.resolve(__dirname, "../src/styles"))) { + expect(readFileSync(path.resolve(__dirname, "../src/styles", f), "utf8")).not.toMatch(/(^|[\s,}])button:disabled\s*\{[^}]*opacity/); + } expect(html(createElement(SparkleButton, { label: "Sign in", disabled: true }))).toContain("disabled"); }); }); +describe("legacy.css", () => { + it("is deleted and no longer imported, and no global button margin rule is left", () => { + expect(existsSync(path.resolve(__dirname, "../src/styles/legacy.css"))).toBe(false); + expect(readFileSync(path.resolve(__dirname, "../src/app/layout.tsx"), "utf8")).not.toContain("legacy.css"); + expect(globals).not.toMatch(/(^|[\s,}])button\s*\{[^}]*margin/); + }); +}); + describe("FlipButton states", () => { it("ready: POST plus send icon, flips to PUBLISH with the icon", () => { expect(flipLabels("ready")).toEqual({ front: "Post", back: "Publish", icon: true });