release: WRNexusJS 0.5.11

This commit is contained in:
2026-07-30 15:03:52 +05:30
parent d1b0c55b53
commit f37303b22d
67 changed files with 530 additions and 213 deletions
+49
View File
@@ -0,0 +1,49 @@
import { describe, expect, test } from "bun:test";
import {
ACCENT_COOKIE,
renderThemeCss,
renderThemeRuntime,
resolveAccentName,
resolveThemeConfig,
} from "../src/theme.ts";
describe("theme accents", () => {
test("uses the configured named palette as the default accent", () => {
const theme = resolveThemeConfig({ palette: "rose", default: "light" });
expect(theme.defaultAccent).toBe("rose");
expect(resolveAccentName(undefined, theme)).toBe("rose");
});
test("validates the accent cookie against enabled palettes", () => {
const theme = resolveThemeConfig({
palette: "rose",
accent: { options: ["rose", "emerald"] },
});
expect(resolveAccentName("emerald", theme)).toBe("emerald");
expect(resolveAccentName("blue", theme)).toBe("rose");
expect(resolveAccentName("not-real", theme)).toBe("rose");
});
test("generates complete palette selectors for light and dark themes", () => {
const css = renderThemeCss(resolveThemeConfig({ palette: "rose" }));
expect(css).toContain('[data-theme="light"][data-accent="emerald"]');
expect(css).toContain('[data-theme="dark"][data-accent="emerald"]');
expect(css).toContain("--wire-color-primary-soft:");
expect(css).toContain("--wire-color-primary-muted:");
expect(css).toContain("--wire-color-primary-text:");
expect(css).toContain("--wire-color-on-primary:");
expect(css).toContain("--wire-color-secondary-soft:");
});
test("runtime persists accents with cookies and never writes inline tokens", () => {
const runtime = renderThemeRuntime(resolveThemeConfig({ palette: "rose" }));
expect(runtime).toContain(ACCENT_COOKIE);
expect(runtime).toContain('el.setAttribute("data-accent",name)');
expect(runtime).not.toContain("localStorage");
expect(runtime).not.toContain("style.setProperty");
});
});