Files
bubbles/help/help_test.go
Ayman Bagabas 8fdc81c836 feat: add a Styler interface for styling bubbles
This change introduces a Styler interface that allows users to define
custom styles for bubbles. The interface is implemented by the StylerFunc
type, which is a function type that takes a boolean argument and returns
a value of any type.

This allows a user to define a custom StylerFunc that returns a custom
style for a bubble based on the background color of the terminal.
2024-10-29 15:54:40 -04:00

40 lines
847 B
Go

package help
import (
"fmt"
"testing"
"github.com/charmbracelet/bubbles/v2/key"
"github.com/charmbracelet/x/ansi"
"github.com/charmbracelet/x/exp/golden"
)
func TestFullHelp(t *testing.T) {
m := New(true)
m.FullSeparator = " | "
k := key.WithKeys("x")
kb := [][]key.Binding{
{
key.NewBinding(k, key.WithHelp("enter", "continue")),
},
{
key.NewBinding(k, key.WithHelp("esc", "back")),
key.NewBinding(k, key.WithHelp("?", "help")),
},
{
key.NewBinding(k, key.WithHelp("H", "home")),
key.NewBinding(k, key.WithHelp("ctrl+c", "quit")),
key.NewBinding(k, key.WithHelp("ctrl+l", "log")),
},
}
for _, w := range []int{20, 30, 40} {
t.Run(fmt.Sprintf("full help %d width", w), func(t *testing.T) {
m.Width = w
s := m.FullHelpView(kb)
s = ansi.Strip(s)
golden.RequireEqual(t, []byte(s))
})
}
}