diff options
Diffstat (limited to 'internal/hexaiaction/tui_test.go')
| -rw-r--r-- | internal/hexaiaction/tui_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/hexaiaction/tui_test.go b/internal/hexaiaction/tui_test.go new file mode 100644 index 0000000..0f7d091 --- /dev/null +++ b/internal/hexaiaction/tui_test.go @@ -0,0 +1,36 @@ +package hexaiaction + +import ( + "testing" + + tea "github.com/charmbracelet/bubbletea" +) + +func TestHandleKey_EscSkips(t *testing.T) { + m := newModel() + nm, _ := handleKey(m, tea.KeyMsg{Type: tea.KeyEsc}) + got, ok := nm.(model) + if !ok || !got.done || got.chosen != ActionSkip { + t.Fatalf("esc should skip: ok=%v done=%v chosen=%v", ok, got.done, got.chosen) + } +} + +func TestHandleKey_QuickHotkey(t *testing.T) { + m := newModel() + nm, _ := handleKey(m, tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'r'}}) + got := nm.(model) + if !got.done || got.chosen != ActionRewrite { + t.Fatalf("r should choose rewrite: done=%v chosen=%v", got.done, got.chosen) + } +} + +func TestHandleKey_JumpEndWithG(t *testing.T) { + m := newModel() + // raw 'G' rune should jump to end (special cased) + nm, _ := handleKey(m, tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'G'}}) + got := nm.(model) + if idx := got.list.Index(); idx != len(got.list.Items())-1 { + t.Fatalf("G should jump to end, index=%d", idx) + } +} + |
