Open History to see the last commit
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 {
7 buildGhosttyThemeConfig,
8 getMobileTerminalTheme,
9 getPierreTerminalTheme,
10} from "./terminalTheme";
11
12describe("getPierreTerminalTheme", () => {
13 it("returns the Pierre light terminal palette", () => {
14 expect(getPierreTerminalTheme("light")).toMatchObject({
15 background: "#f2f2f7",
16 foreground: "#6C6C71",
17 cursorForeground: "#009fff",
18 cursorBackground: "#f2f2f7",
19 });
20 });
21
22 it("returns the Pierre dark terminal palette", () => {
23 expect(getPierreTerminalTheme("dark")).toMatchObject({
24 background: "#0a0a0a",
25 foreground: "#adadb1",
26 cursorForeground: "#009fff",
27 cursorBackground: "#0a0a0a",
28 });
29 });
30});
31
32describe("getMobileTerminalTheme", () => {
33 it("preserves the Pierre terminal for the default theme", () => {
34 for (const scheme of ["light", "dark"] as const) {
35 expect(getMobileTerminalTheme("t3-code", scheme)).toEqual(getPierreTerminalTheme(scheme));
36 }
37 });
38
39 it("applies the selected palette without replacing ANSI status colors", () => {
40 const standard = getMobileTerminalTheme("t3-code", "dark");
41 const ocean = getMobileTerminalTheme("ocean", "dark");
42
43 expect(ocean.background).not.toBe(standard.background);
44 expect(ocean.cursorForeground).not.toBe(standard.cursorForeground);
45 expect(ocean.palette).toEqual(standard.palette);
46 });
47
48 it("uses the canonical desktop terminal roles for built-in themes", () => {
49 const theme = BUILT_IN_THEMES.find((candidate) => candidate.id === "ocean")!;
50 const colors = getThemeColorsForAppearance(theme, "dark")!;
51 const terminal = getMobileTerminalTheme("ocean", "dark");
52
53 expect(terminal.background).toBe(themeColorToNativeColor(colors.terminalBackground));
54 expect(terminal.foreground).toBe(themeColorToNativeColor(colors.terminalForeground));
55 expect(terminal.cursorForeground).toBe(themeColorToNativeColor(colors.terminalCursor));
56 });
57});
58
59describe("buildGhosttyThemeConfig", () => {
60 it("serializes theme colors into a ghostty config file", () => {
61 const config = buildGhosttyThemeConfig(getPierreTerminalTheme("dark"));
62
63 expect(config).toContain("background = #0a0a0a");
64 expect(config).toContain("foreground = #adadb1");
65 expect(config).toContain("cursor-color = #009fff");
66 expect(config).toContain("palette = 0=#141415");
67 expect(config).toContain("palette = 15=#c6c6c8");
68 expect(config.endsWith("\n")).toBe(true);
69 });
70});