fix(help): fix test by downsampling color to NoTTY

This commit is contained in:
Christian Rocha
2024-10-23 22:09:31 -04:00
parent 4b2f72baa9
commit 89f2eef648
+14 -1
View File
@@ -2,8 +2,11 @@ package help
import (
"fmt"
"os"
"strings"
"testing"
"github.com/charmbracelet/colorprofile"
"github.com/charmbracelet/x/exp/golden"
"github.com/charmbracelet/bubbles/v2/key"
@@ -32,7 +35,17 @@ func TestFullHelp(t *testing.T) {
t.Run(fmt.Sprintf("full help %d width", w), func(t *testing.T) {
m.Width = w
s := m.FullHelpView(kb)
golden.RequireEqual(t, []byte(s))
// Downsample color to NoTTY mode.
var b strings.Builder
downsampler := colorprofile.NewWriter(&b, os.Environ())
downsampler.Profile = colorprofile.NoTTY
_, err := downsampler.WriteString(s)
if err != nil {
t.Error(err)
}
golden.RequireEqual(t, []byte(b.String()))
})
}
}