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

Function TestHistoryDownRestoresUnsentDraft

internal/tui/tui_test.go:524–538  ·  view source on GitHub ↗

TestHistoryDownRestoresUnsentDraft: an unsent draft survives a ↑ into history and is restored when ↓ walks back to the live line.

(t *testing.T)

Source from the content-addressed store, hash-verified

522// TestHistoryDownRestoresUnsentDraft: an unsent draft survives a ↑ into history
523// and is restored when ↓ walks back to the live line.
524func TestHistoryDownRestoresUnsentDraft(t *testing.T) {
525 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
526 m.promptHistory = []promptEntry{{display: "old prompt"}}
527 m.histIdx = -1
528 m.ta.SetValue("my unsent draft")
529
530 mm, _ := m.Update(tea.KeyMsg{Type: tea.KeyUp})
531 if got := mm.(Model).ta.Value(); got != "old prompt" {
532 t.Fatalf("↑ should replay history, got %q", got)
533 }
534 mm2, _ := mm.(Model).Update(tea.KeyMsg{Type: tea.KeyDown})
535 if got := mm2.(Model).ta.Value(); got != "my unsent draft" {
536 t.Fatalf("↓ should restore the unsent draft, got %q", got)
537 }
538}
539
540// TestHistoryPushesOnSubmit: successful submit appends to promptHistory and
541// resets the walker index to -1.

Callers

nothing calls this directly

Calls 4

newTestModelFunction · 0.85
SetValueMethod · 0.80
ValueMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected