chore(help): add full help test to support #554

This commit is contained in:
Christian Rocha
2024-10-11 11:17:18 -04:00
parent 81d444a207
commit 60796500b2
6 changed files with 47 additions and 3 deletions
+38
View File
@@ -0,0 +1,38 @@
package help
import (
"fmt"
"testing"
"github.com/charmbracelet/x/exp/golden"
"github.com/charmbracelet/bubbles/key"
)
func TestFullHelp(t *testing.T) {
m := New()
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)
golden.RequireEqual(t, []byte(s))
})
}
}
+1
View File
@@ -0,0 +1 @@
enter continue …
+2
View File
@@ -0,0 +1,2 @@
enter continue | esc back …
? help
+3
View File
@@ -0,0 +1,3 @@
enter continue | esc back | H home
? help ctrl+c quit
ctrl+l log