/** * @file Dashboard.heatmap.test.ts * @description Pins the activity heatmap's colour ramp to the theme tokens: it * runs from the page surface to the accent in every theme, instead of a fixed * near-black indigo that vanished into dark and blotted out light themes. * @author Nguyễn Ngọc Trí Vĩ */ import { describe, it, expect } from "vitest"; import { cellColor } from "../Dashboard"; describe("heatmap cellColor", () => { it("paints an empty day as the bare surface", () => { expect(cellColor(0, 10)).toBe("rgb(var(--surface-0))"); }); it("mixes the accent into the surface, more for busier days, and never a fixed rgb", () => { const low = cellColor(1, 100); const high = cellColor(100, 100); for (const c of [low, high]) { expect(c).toMatch( /^color-mix\(in srgb, rgb\(var\(--accent\)\) \d+%, rgb\(var\(--surface-0\)\)\)$/ ); } const pct = (c: string) => Number(/(\d+)%/.exec(c)?.[1]); expect(pct(high)).toBe(100); expect(pct(low)).toBeGreaterThan(0); expect(pct(low)).toBeLessThan(pct(high)); }); });