-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(help): add full help test to support #554
- Loading branch information
1 parent
81d444a
commit 2bf3c84
Showing
6 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
enter continue … |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
enter continue | esc back … | ||
? help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
enter continue | esc back | H home | ||
? help ctrl+c quit | ||
ctrl+l log |