import { describe, expect, it } from "bun:test"; import tokens from "../src/shared/tokens.css" with { type: "text" }; // Dark mode lets a host (the docs site) tune two colors through VitePress-style // variables. A host that sets neither, such as VS Code or `gram view --serve`, // must render exactly as before: these fallbacks are their colors. function darkToken(name: string): string | undefined { const block = tokens.match(/:root\[data-theme="dark"\]\s*\{([^}]*)\}/)?.[1]; return block ?.match(new RegExp(`${name}:\\s*([^;]+);`))?.[1] .replace(/\s+/g, " ") .trim(); } describe("dark mode host hooks", () => { it("the background falls back to #1a1a1a", () => { expect(tokens).toContain("--bg-dark-anchor: var(--vp-c-bg, #1a1a1a);"); }); it("the strongest text falls back to pure white", () => { expect(darkToken("--color-text-strong")).toBe( "var(--vp-c-text-1, oklch(100% 0 0))", ); }); });