import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import test from "node:test"; const stylesheet = await readFile( new URL("../src/index.css", import.meta.url), "utf8", ); const BRAND_COLORS = { coral: "oklch(70.8008% .234375 24)", ink: "#22252e", gold: "#f2b01e", leaf: "#2f9e58", } as const; test("defines each brand color once as a primitive token", () => { for (const [name, value] of Object.entries(BRAND_COLORS)) { assert.match( stylesheet, new RegExp(`--color-brand-${name}: ${escapeRegExp(value)};`), ); assert.equal( stylesheet.split(value).length - 1, 1, `${name} should have one literal source`, ); } }); test("keeps the layer order that lets LOLYMPUS tokens override Astryx", () => { assert.match( stylesheet, /@layer reset, theme, base, astryx-base, astryx-theme, lolympus, components, utilities;/, ); assert.doesNotMatch(stylesheet, /daisyui/); }); test("derives Astryx action colors from the brand coral", () => { assert.match( stylesheet, /--color-accent: var\(--color-brand-coral\);/, ); assert.match( stylesheet, /--color-text-accent: light-dark\(\s*color-mix\(in oklab, var\(--color-brand-coral\) \d+%, black\),\s*color-mix\(in oklab, var\(--color-brand-coral\) \d+%, white\)\s*\);/, ); }); test("separates fill and text colors for primary and result roles", () => { const mappings = [ ["--color-primary", "--color-accent"], ["--text-color-primary", "--color-text-accent"], ["--color-win", "--lts-win-fill"], ["--text-color-win", "--lts-win"], ["--color-loss", "--lts-loss-fill"], ["--text-color-loss", "--lts-loss"], ["--color-bracket-winner", "--color-text-accent"], ] as const; for (const [utilityToken, roleToken] of mappings) { assert.match( stylesheet, new RegExp( `${escapeRegExp(utilityToken)}: var\\(${escapeRegExp(roleToken)}\\);`, ), ); } }); test("defines every role color for both light and dark", () => { const roleTokens = [ "--lts-ink", "--lts-win", "--lts-win-tint", "--lts-loss", "--lts-loss-tint", "--lts-gold", "--lts-leaf", "--lts-sunken", ]; for (const token of roleTokens) { assert.match( stylesheet, new RegExp(`${escapeRegExp(token)}: light-dark\\(`), `${token} should use light-dark()`, ); } }); function escapeRegExp(value: string): string { return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); }