package ghostty import ( "os" "path/filepath" "slices" "testing" ) func TestLoadThemeExpandsHome(t *testing.T) { home := t.TempDir() t.Setenv("HOME", home) dir := filepath.Join(home, "themes") if err := os.MkdirAll(dir, 0o755); err != nil { t.Fatal(err) } theme := "background = #252528\npalette = 1=#f38ba8\n" if err := os.WriteFile(filepath.Join(dir, "mine"), []byte(theme), 0o644); err != nil { t.Fatal(err) } th, err := (&Ghostty{}).LoadTheme("~/themes/mine") if err != nil { t.Fatal(err) } if th.Background != "#252528" || th.Palette[1] != "#f38ba8" { t.Errorf("theme: %+v", th) } } // Ghostty looks for user themes in the XDG config directory only, also on // macOS, where the config file usually lives under Application Support. func TestThemeDirsFollowGhostty(t *testing.T) { home := t.TempDir() t.Setenv("HOME", home) t.Setenv("XDG_CONFIG_HOME", "") t.Setenv("GHOSTTY_RESOURCES_DIR", "") got := (&Ghostty{}).ThemeDirs() want := []string{filepath.Join(home, ".config", "ghostty", "themes")} if !slices.Equal(got, want) { t.Errorf("ThemeDirs = %v, want %v", got, want) } }