package theme import ( "testing" "github.com/charmbracelet/lipgloss" ) func allThemes() []Theme { return []Theme{FlexokiLight(), FlexokiDark(), Charm()} } func TestEveryThemeHasAllColorsSet(t *testing.T) { for _, th := range allThemes() { colors := map[string]lipgloss.Color{ "Text": th.Text, "Emphasis": th.Emphasis, "Heading": th.Heading, "Code": th.Code, "Link": th.Link, "Wikilink": th.Wikilink, "ListMarker": th.ListMarker, "Blockquote": th.Blockquote, "Comment": th.Comment, "Accent": th.Accent, "Highlight": th.Highlight, "Background": th.Background, "Muted": th.Muted, "StatusFg": th.StatusFg, "StatusBg": th.StatusBg, "SelFg": th.SelFg, "SelBg": th.SelBg, "Pointer": th.Pointer, } for name, c := range colors { if c == "" { t.Errorf("theme %q: color %s is empty", th.Name, name) } } if th.Name == "" { t.Error("theme has empty Name") } if th.GlamourStyle == "" { t.Errorf("theme %q has empty GlamourStyle", th.Name) } } } func TestByName(t *testing.T) { for _, name := range CycleOrder { if _, ok := ByName(name); !ok { t.Errorf("ByName(%q) not found", name) } } if _, ok := ByName("nope"); ok { t.Error("ByName(nope) should not be found") } } func TestNextCycles(t *testing.T) { if Next("flexoki-light").Name != "flexoki-dark" { t.Error("light -> dark") } if Next("flexoki-dark").Name != "charm" { t.Error("dark -> charm") } if Next("charm").Name != "flexoki-light" { t.Error("charm -> light (wrap)") } // Unknown name starts the cycle at the first entry's successor is well-defined: if Next("unknown").Name != CycleOrder[0] { t.Errorf("unknown -> %s, want %s", Next("unknown").Name, CycleOrder[0]) } } func TestResolve(t *testing.T) { if Resolve("charm").Name != "charm" { t.Error("explicit name should resolve to itself") } // auto and unknown both fall back to OS detection — must be a real registered theme. for _, v := range []string{"auto", "", "bogus"} { got := Resolve(v) if _, ok := ByName(got.Name); !ok { t.Errorf("Resolve(%q) returned unregistered theme %q", v, got.Name) } } }