1import { describe, expect, it } from "vite-plus/test";
2import { BUILT_IN_THEMES, getThemeColorsForAppearance } from "@t3tools/shared/themePalettes";
3
4import { themeColorToNativeColor } from "../../lib/mobileTheme";
5
6import { buildGhosttyThemeConfig, getMobileTerminalTheme } from "./terminalTheme";
7
8describe("getMobileTerminalTheme", () => {
9 it("uses the shared default light terminal colors", () => {
10 expect(getMobileTerminalTheme("t3-code", "light")).toMatchObject({
11 background: "#fcfcfc",
12 foreground: "#27272a",
13 cursorForeground: "#26384e",
14 cursorBackground: "#fcfcfc",
15 });
16 });
17
18 it("uses the shared default dark terminal colors", () => {
19 expect(getMobileTerminalTheme("t3-code", "dark")).toMatchObject({
20 background: "#0a0a0a",
21 foreground: "#f5f5f5",
22 cursorForeground: "#b4cbff",
23 cursorBackground: "#0a0a0a",
24 });
25 });
26 it("applies the selected palette without replacing ANSI status colors", () => {
27 const standard = getMobileTerminalTheme("t3-code", "dark");
28 const ocean = getMobileTerminalTheme("ocean", "dark");
29
30 expect(ocean.background).not.toBe(standard.background);
31 expect(ocean.cursorForeground).not.toBe(standard.cursorForeground);
32 expect(ocean.palette).toEqual(standard.palette);
33 });
34
35 it("uses the canonical desktop terminal roles for built-in themes", () => {
36 const theme = BUILT_IN_THEMES.find((candidate) => candidate.id === "ocean")!;
37 const colors = getThemeColorsForAppearance(theme, "dark")!;
38 const terminal = getMobileTerminalTheme("ocean", "dark");
39
40 expect(terminal.background).toBe(themeColorToNativeColor(colors.terminalBackground));
41 expect(terminal.foreground).toBe(themeColorToNativeColor(colors.terminalForeground));
42 expect(terminal.cursorForeground).toBe(themeColorToNativeColor(colors.terminalCursor));
43 });
44});
45
46describe("buildGhosttyThemeConfig", () => {
47 it("serializes theme colors into a ghostty config file", () => {
48 const config = buildGhosttyThemeConfig(getMobileTerminalTheme("t3-code", "dark"));
49
50 expect(config).toContain("background = #0a0a0a");
51 expect(config).toContain("foreground = #f5f5f5");
52 expect(config).toContain("cursor-color = #b4cbff");
53 expect(config).toContain("palette = 0=#141415");
54 expect(config).toContain("palette = 15=#c6c6c8");
55 expect(config.endsWith("\n")).toBe(true);
56 });
57});