@@ -0,0 +1,147 @@
8+ "github.com/charmbracelet/crush/internal/tui/components/core"
9+ "github.com/charmbracelet/x/exp/golden"
12+func TestStatus(t *testing.T) {
22+ opts: core.StatusOpts{
24+ Description: "Everything is working fine",
29+ name: "WithCustomIcon",
30+ opts: core.StatusOpts{
33+ Description: "Operation completed successfully",
39+ opts: core.StatusOpts{
42+ Description: "This status has no icon",
48+ opts: core.StatusOpts{
50+ IconColor: color.RGBA{255, 165, 0, 255}, // Orange
52+ TitleColor: color.RGBA{255, 255, 0, 255}, // Yellow
53+ Description: "This is a warning message",
54+ DescriptionColor: color.RGBA{255, 0, 0, 255}, // Red
59+ name: "WithExtraContent",
60+ opts: core.StatusOpts{
62+ Description: "Building project",
63+ ExtraContent: "[2/5]",
68+ name: "LongDescription",
69+ opts: core.StatusOpts{
71+ Description: "This is a very long description that should be truncated when the width is too small to display it completely without wrapping",
77+ opts: core.StatusOpts{
80+ Description: "Short message",
85+ name: "VeryNarrowWidth",
86+ opts: core.StatusOpts{
89+ Description: "This will be truncated",
94+ name: "EmptyDescription",
95+ opts: core.StatusOpts{
102+ name: "AllFieldsWithExtraContent",
103+ opts: core.StatusOpts{
105+ IconColor: color.RGBA{0, 255, 0, 255}, // Green
106+ Title: "Deployment",
107+ TitleColor: color.RGBA{0, 0, 255, 255}, // Blue
108+ Description: "Deploying to production environment",
109+ DescriptionColor: color.RGBA{128, 128, 128, 255}, // Gray
110+ ExtraContent: "v1.2.3",
116+ for _, tt := range tests {
117+ t.Run(tt.name, func(t *testing.T) {
120+ output := core.Status(tt.opts, tt.width)
121+ golden.RequireEqual(t, []byte(output))
126+func TestStatusTruncation(t *testing.T) {
129+ opts := core.StatusOpts{
131+ Title: "Very Long Title",
132+ Description: "This is an extremely long description that definitely needs to be truncated",
133+ ExtraContent: "[extra]",
136+ // Test different widths to ensure truncation works correctly
137+ widths := []int{20, 30, 40, 50, 60}
139+ for _, width := range widths {
140+ t.Run(fmt.Sprintf("Width%d", width), func(t *testing.T) {
143+ output := core.Status(opts, width)
144+ golden.RequireEqual(t, []byte(output))