MCPcopy Create free account
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

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

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