Skip to content

Commit

Permalink
fix(help): fix test by downsampling color to NoTTY
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Oct 24, 2024
1 parent 4b2f72b commit 89f2eef
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion help/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()))
})
}
}

0 comments on commit 89f2eef

Please sign in to comment.