MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestPopoverTabOnEmptyOpensCommandList

Function TestPopoverTabOnEmptyOpensCommandList

internal/tui/tui_test.go:301–323  ·  view source on GitHub ↗

TestPopoverTabOnEmptyOpensCommandList: Tab on an empty textarea is equivalent to typing "/": it opens the popover with the full command list. Subsequent Tabs cycle.

(t *testing.T)

Source from the content-addressed store, hash-verified

299// equivalent to typing "/": it opens the popover with the full command
300// list. Subsequent Tabs cycle.
301func TestPopoverTabOnEmptyOpensCommandList(t *testing.T) {
302 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
303 if m.ta.Value() != "" || m.popoverOpen() {
304 t.Fatal("precondition: empty textarea, popover closed")
305 }
306 mm, _ := m.Update(tea.KeyMsg{Type: tea.KeyTab})
307 om := mm.(Model)
308 if !om.popoverOpen() {
309 t.Fatal("Tab on empty should open the command popover")
310 }
311 if om.ta.Value() != "/" {
312 t.Fatalf("textarea should be seeded with '/' got %q", om.ta.Value())
313 }
314 if len(om.suggest) != len(commands) {
315 t.Fatalf("popover should show all commands, got %d of %d",
316 len(om.suggest), len(commands))
317 }
318 // second Tab cycles (selection moves from 0 to 1)
319 mm2, _ := om.Update(tea.KeyMsg{Type: tea.KeyTab})
320 if mm2.(Model).suggestIdx != 1 {
321 t.Fatalf("second Tab should cycle to idx 1, got %d", mm2.(Model).suggestIdx)
322 }
323}
324
325// TestPopoverTabCompletesUniquePrefix: with one match, Tab completes the name
326// and, because /models takes args, appends a space that flips the popover into

Callers

nothing calls this directly

Calls 4

newTestModelFunction · 0.85
ValueMethod · 0.80
popoverOpenMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected