The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { defaultThemeGeneration, defaultThemeToApply, themeSetsOwnMode } from "./useDefaultTheme"; |
| 4 | |
| 5 | const 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 | |
| 13 | describe("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 | |
| 30 | it("applies the stock theme only when the environment set it", () => { |
| 31 | expect(defaultThemeToApply({ ...BASE, defaultTheme: "", defaultThemeSetAt: "" })).toBe(null); |
| 32 | expect(defaultThemeToApply({ ...BASE, defaultTheme: "" })).not.toBe(null); |
| 33 | }); |
| 34 | }); |
| 35 | |
| 36 | it("lets a theme set its own mode only when no mode was set with it or after it", () => { |
| 37 | const theme = "2026-11-13T10:00:00.000Z"; |
| 38 | const set = (defaultAppearance: string, defaultAppearanceSetAt: string) => |
| 39 | themeSetsOwnMode({ defaultThemeSetAt: theme, defaultAppearance, defaultAppearanceSetAt }); |
| 40 | expect(set("", "")).toBe(true); |
| 41 | expect(set("dark", "2026-11-13T09:00:00.000Z")).toBe(true); |
| 42 | expect(set("dark", theme)).toBe(false); |
| 43 | expect(set("light", "2026-11-13T11:00:00.000Z")).toBe(false); |
| 44 | }); |