8 "github.com/charmbracelet/crush/internal/tui/components/core"
9 "github.com/charmbracelet/x/exp/golden"
12func 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{
41 Description: "This status has no icon",
47 opts: core.StatusOpts{
50 TitleColor: color.RGBA{255, 255, 0, 255}, // Yellow
51 Description: "This is a warning message",
52 DescriptionColor: color.RGBA{255, 0, 0, 255}, // Red
57 name: "WithExtraContent",
58 opts: core.StatusOpts{
60 Description: "Building project",
61 ExtraContent: "[2/5]",
66 name: "LongDescription",
67 opts: core.StatusOpts{
69 Description: "This is a very long description that should be truncated when the width is too small to display it completely without wrapping",
75 opts: core.StatusOpts{
78 Description: "Short message",
83 name: "VeryNarrowWidth",
84 opts: core.StatusOpts{
87 Description: "This will be truncated",
92 name: "EmptyDescription",
93 opts: core.StatusOpts{
100 name: "AllFieldsWithExtraContent",
101 opts: core.StatusOpts{
104 TitleColor: color.RGBA{0, 0, 255, 255}, // Blue
105 Description: "Deploying to production environment",
106 DescriptionColor: color.RGBA{128, 128, 128, 255}, // Gray
107 ExtraContent: "v1.2.3",
113 for _, tt := range tests {
114 t.Run(tt.name, func(t *testing.T) {
117 output := core.Status(tt.opts, tt.width)
118 golden.RequireEqual(t, []byte(output))
123func TestStatusTruncation(t *testing.T) {
126 opts := core.StatusOpts{
128 Title: "Very Long Title",
129 Description: "This is an extremely long description that definitely needs to be truncated",
130 ExtraContent: "[extra]",
133 // Test different widths to ensure truncation works correctly
134 widths := []int{20, 30, 40, 50, 60}
136 for _, width := range widths {
137 t.Run(fmt.Sprintf("Width%d", width), func(t *testing.T) {
140 output := core.Status(opts, width)
141 golden.RequireEqual(t, []byte(output))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list