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

Function TestEscFromCommandLevelClosesAndClears

internal/tui/tui_test.go:377–393  ·  view source on GitHub ↗

TestEscFromCommandLevelClosesAndClears: Esc at command-level closes the popover AND clears the textarea, so the user returns to a blank prompt. Typing "/" from the blank slate re-opens the popover from scratch.

(t *testing.T)

Source from the content-addressed store, hash-verified

375// popover AND clears the textarea, so the user returns to a blank prompt.
376// Typing "/" from the blank slate re-opens the popover from scratch.
377func TestEscFromCommandLevelClosesAndClears(t *testing.T) {
378 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
379 mm := typeInto(m, "/")
380 mm2, _ := mm.Update(tea.KeyMsg{Type: tea.KeyEsc})
381 om := mm2.(Model)
382 if om.popoverOpen() {
383 t.Fatal("Esc should close popover")
384 }
385 if om.ta.Value() != "" {
386 t.Fatalf("Esc at command-level should clear textarea, got %q", om.ta.Value())
387 }
388 // Typing "/" from a blank slate re-opens the popover.
389 mm3 := typeInto(om, "/")
390 if !mm3.popoverOpen() {
391 t.Fatal("typing '/' after Esc should re-open popover")
392 }
393}
394
395// TestPopoverArrowKeysMoveSelection: while popover is open, ↑/↓ move the
396// selection (NOT arrow history), and the textarea is not clobbered.

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected