import { describe, expect, it } from "vitest"; import { parseDTCGFile } from "../dtcg-parser.js"; import { parseColor as parseStyleColor } from "../style-comparison.js"; import { parseTokenFile } from "../token-parser.js"; import { parseColor, parseDtcgTokens, parseScssTokens, parseTokens, } from "../tokens/index.js"; describe("token module compatibility", () => { it("keeps the old SCSS parser path wired to the core token module", () => { const css = ` // Colors :root { --fui-color-accent: #ff0000; --fui-color-brand: var(--fui-color-accent); } `; expect(parseTokenFile).toBe(parseScssTokens); expect(parseTokenFile(css, "tokens.scss")).toEqual( parseTokens(css, { format: "scss", filePath: "tokens.scss" }), ); }); it("keeps the old DTCG parser path wired to the core token module", () => { const content = JSON.stringify({ color: { $type: "color", accent: { $value: "#3b82f6" }, }, }); expect(parseDTCGFile).toBe(parseDtcgTokens); expect(parseDTCGFile(content, "brand.tokens.json")).toEqual( parseTokens(content, { format: "dtcg", filePath: "brand.tokens.json" }), ); }); it("uses the same color parser in style comparison and the token module", () => { expect(parseStyleColor).toBe(parseColor); expect(parseStyleColor("rgb(255, 0, 0)")).toEqual({ r: 255, g: 0, b: 0, a: 1, }); }); });