release: WRNexusJS 0.2.57

This commit is contained in:
2026-07-19 17:45:13 +05:30
parent 14e2878417
commit c0c09426ff
65 changed files with 487 additions and 103 deletions
+39
View File
@@ -1,11 +1,50 @@
import { test, expect } from "bun:test";
import {
THEME_PALETTE_NAMES,
THEME_PALETTES,
resolveThemeConfig,
resolveThemeName,
renderThemeCss,
renderThemeRuntime,
} from "../src/index.ts";
test("ships eight complete semantic color palettes", () => {
expect(THEME_PALETTE_NAMES).toHaveLength(8);
for (const name of THEME_PALETTE_NAMES) {
expect(Object.keys(THEME_PALETTES[name])).toEqual([
"primary",
"primaryHover",
"primaryContrast",
"secondary",
"secondaryHover",
"secondaryContrast",
"info",
"success",
"warning",
"danger",
]);
}
});
test("named palettes populate semantic tokens in every theme", () => {
const t = resolveThemeConfig({ palette: "violet" });
for (const name of t.names) {
expect(t.themes[name]["color-primary"]).toBe(THEME_PALETTES.violet.primary);
expect(t.themes[name]["color-secondary"]).toBe(THEME_PALETTES.violet.secondary);
expect(t.themes[name]["color-info"]).toBe(THEME_PALETTES.violet.info);
expect(t.themes[name]["color-error"]).toBe(THEME_PALETTES.violet.danger);
}
});
test("custom palettes require every semantic color", () => {
expect(() => resolveThemeConfig({ palette: { primary: "#000" } as never })).toThrow(
"primaryHover, primaryContrast, secondary",
);
expect(() => resolveThemeConfig({ palette: "unknown" as never })).toThrow(
"Unknown theme palette",
);
});
test("resolveThemeConfig merges user tokens over built-in light/dark", () => {
const t = resolveThemeConfig({ default: "dark", themes: { dark: { "color-primary": "#abc" } } });
expect(t.default).toBe("dark");