24 lines
726 B
TypeScript
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\(/);
|
|
});
|