Skip to content
Source
Sign inSign up

useDefaultTheme.test.ts

29 lines1003 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { defaultThemeGeneration, defaultThemeToApply } from "./useDefaultTheme";
4​
5const BASE = {
6 environmentId: "env-1",
7 defaultTheme: "nightfall",
8 defaultThemeSetAt: "2026-08-28T00:00:00.000Z",
9 appliedGeneration: null,
10 resolves: true,
11} as const;
12​
13describe("default theme adoption", () => {
14 it("does not replay a generation it already applied", () => {
15 const generation = defaultThemeGeneration(BASE.defaultTheme, BASE.defaultThemeSetAt);
16 expect(defaultThemeToApply({ ...BASE, appliedGeneration: generation })).toBe(null);
17 });
18​
19 it("applies the same theme again when the environment re-sets it", () => {
20 const applied = defaultThemeGeneration(BASE.defaultTheme, "2026-08-28T00:00:00.000Z");
21 const next = defaultThemeToApply({
22 ...BASE,
23 defaultThemeSetAt: "2026-08-29T00:00:00.000Z",
24 appliedGeneration: applied,
25 });
26 expect(next).not.toBe(null);
27 expect(next).not.toBe(applied);
28 });
29});