forked from pterm/pterm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteractive_select_printer_test.go
35 lines (29 loc) · 1.04 KB
/
interactive_select_printer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package pterm_test
import (
"testing"
"atomicgo.dev/keyboard"
"atomicgo.dev/keyboard/keys"
"github.com/MarvinJWendt/testza"
"github.com/pterm/pterm"
)
func TestInteractiveSelectPrinter_Show(t *testing.T) {
go func() {
keyboard.SimulateKeyPress(keys.Down)
keyboard.SimulateKeyPress(keys.Down)
keyboard.SimulateKeyPress(keys.Enter)
}()
result, _ := pterm.DefaultInteractiveSelect.WithOptions([]string{"a", "b", "c", "d", "e"}).WithDefaultOption("b").Show()
testza.AssertEqual(t, "d", result)
}
func TestInteractiveSelectPrinter_WithDefaultOption(t *testing.T) {
p := pterm.DefaultInteractiveSelect.WithDefaultOption("default")
testza.AssertEqual(t, p.DefaultOption, "default")
}
func TestInteractiveSelectPrinter_WithOptions(t *testing.T) {
p := pterm.DefaultInteractiveSelect.WithOptions([]string{"a", "b", "c"})
testza.AssertEqual(t, p.Options, []string{"a", "b", "c"})
}
func TestInteractiveSelectPrinter_WithMaxHeight(t *testing.T) {
p := pterm.DefaultInteractiveSelect.WithMaxHeight(1337)
testza.AssertEqual(t, p.MaxHeight, 1337)
}