From 89f2eef6486a11d7e92d74248b8a8d22830f6159 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 23 Oct 2024 22:09:31 -0400 Subject: [PATCH] fix(help): fix test by downsampling color to NoTTY --- help/help_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/help/help_test.go b/help/help_test.go index c3e1101..294b9e6 100644 --- a/help/help_test.go +++ b/help/help_test.go @@ -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())) }) } }