Files
webdev-pipeline/tests/dashboard-theme.test.ts
2026-06-05 16:47:22 +02:00

24 lines
726 B
TypeScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import test from "node:test";
const dashboardThemePath = join(
process.cwd(),
"components",
"dashboard-theme.tsx",
);
test("DashboardThemeProvider keeps server and first client render stable", async () => {
const source = await readFile(dashboardThemePath, "utf8");
assert.match(source, /useSyncExternalStore\(/);
assert.match(source, /function getServerDashboardTheme\(\): DashboardTheme \{/);
assert.match(source, /return "light";/);
assert.doesNotMatch(
source,
/useState<DashboardTheme>\(\(\) => \{[\s\S]*?localStorage/,
);
assert.doesNotMatch(source, /setTheme\(/);
});