1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
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)
}
}
}
|