Repository navigation
Expand file tree
/
Copy pathbraille_spinner_test.go
More file actions
94 lines (86 loc) · 2.56 KB
/
Copy pathbraille_spinner_test.go
File metadata and controls
94 lines (86 loc) · 2.56 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package cmd
import (
"strings"
"testing"
"github.com/GrayCodeAI/reflect/internal/ui/icons"
)
func TestBrailleSpinner_Tick(t *testing.T) {
s := NewBrailleSpinner(SpinnerBraille, "Thinking")
f1 := s.Frame()
f2 := s.Tick()
if f1 == f2 {
t.Error("expected different frames after tick")
}
// Glyph uses the 20-color wave (not fixed orange).
if !frameContainsSpinnerWave(f1) {
t.Error("expected wave-colored spinner glyph")
}
// Verb + dots use the 20-color wave palette.
if !frameContainsSpinnerWave(f1) {
t.Error("expected wave-colored verb label")
}
if !strings.Contains(f1, icons.CircleFilled()) {
t.Error("expected filled typing dot")
}
}
func TestBrailleSpinner_AllStyles(t *testing.T) {
styles := []SpinnerStyle{
SpinnerBraille, SpinnerBrailleWave, SpinnerReflect, SpinnerDNA,
SpinnerScan, SpinnerPulse, SpinnerSnake, SpinnerOrbit,
SpinnerWing, SpinnerTalons,
}
for _, style := range styles {
s := NewBrailleSpinner(style, "test")
f := s.Frame()
if f == "" {
t.Errorf("style %s produced empty frame", style)
}
}
}
func TestBrailleSpinner_Random(t *testing.T) {
s := NewBrailleSpinner(SpinnerRandom, "Loading")
f := s.Frame()
if f == "" {
t.Error("random spinner produced empty frame")
}
}
func TestReflectSpinner_Frames(t *testing.T) {
if len(reflectSpinnerGlyphs) != 4 {
t.Fatalf("expected 4 compass glyphs, got %d", len(reflectSpinnerGlyphs))
}
if reflectSpinnerGlyphs[0] != "◐" {
t.Fatalf("expected first compass frame ◐, got %q", reflectSpinnerGlyphs[0])
}
s := NewBrailleSpinner(SpinnerReflect, "Working")
f0 := s.Frame()
if !strings.Contains(f0, "◐") {
t.Fatalf("expected compass glyph, got %q", f0)
}
s.Tick()
s.Tick()
s.Tick()
if !strings.Contains(s.Frame(), "◒") {
t.Fatalf("expected frame cycle to reach ◒, got %q", s.Frame())
}
}
func TestReflectQuadBlock_LegacyFrames(t *testing.T) {
s := NewBrailleSpinner(SpinnerReflectQuad, "Working")
if !strings.Contains(s.Frame(), "▛") {
t.Fatalf("expected QuadBlock glyph, got %q", s.Frame())
}
}
func TestReflectAnimatedDots_PresentInFrame(t *testing.T) {
s := NewBrailleSpinner(SpinnerReflect, "Crafting")
f := s.Frame()
// Three progress dots ride after the verb: one bright, two dim.
total := strings.Count(f, icons.CircleFilled()) + strings.Count(f, icons.CircleOutline())
if total != reflectTypingDots {
t.Errorf("expected %d trailing circle-dots, got %d in %q", reflectTypingDots, total, f)
}
// Tick advances the highlighted dot position.
idxBefore := s.dots
s.Tick()
if s.dots == idxBefore {
t.Error("expected dot phase to advance on tick")
}
}