MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestHistoryUpDownReplayLastSubmission

Function TestHistoryUpDownReplayLastSubmission

internal/tui/tui_test.go:491–520  ·  view source on GitHub ↗

TestHistoryUpDownReplayLastSubmission: ↑ on first-line replaces textarea with the most recent submitted line; ↓ steps back toward the draft.

(t *testing.T)

Source from the content-addressed store, hash-verified

489// TestHistoryUpDownReplayLastSubmission: ↑ on first-line replaces textarea
490// with the most recent submitted line; ↓ steps back toward the draft.
491func TestHistoryUpDownReplayLastSubmission(t *testing.T) {
492 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
493 m.promptHistory = []promptEntry{{display: "first question"}, {display: "second question"}}
494 m.histIdx = -1
495
496 mm, _ := m.Update(tea.KeyMsg{Type: tea.KeyUp})
497 if got := mm.(Model).ta.Value(); got != "second question" {
498 t.Fatalf("↑ should replay newest, got %q", got)
499 }
500 mm2, _ := mm.(Model).Update(tea.KeyMsg{Type: tea.KeyUp})
501 if got := mm2.(Model).ta.Value(); got != "first question" {
502 t.Fatalf("↑↑ should replay oldest, got %q", got)
503 }
504 mm3, _ := mm2.(Model).Update(tea.KeyMsg{Type: tea.KeyUp})
505 if got := mm3.(Model).ta.Value(); got != "first question" {
506 t.Fatalf("↑ past oldest should stay, got %q", got)
507 }
508 mm4, _ := mm3.(Model).Update(tea.KeyMsg{Type: tea.KeyDown})
509 if got := mm4.(Model).ta.Value(); got != "second question" {
510 t.Fatalf("↓ should move toward draft, got %q", got)
511 }
512 mm5, _ := mm4.(Model).Update(tea.KeyMsg{Type: tea.KeyDown})
513 if got := mm5.(Model).ta.Value(); got != "" {
514 t.Fatalf("↓ past newest should restore empty draft, got %q", got)
515 }
516 mm6, _ := mm5.(Model).Update(tea.KeyMsg{Type: tea.KeyDown})
517 if got := mm6.(Model).ta.Value(); got != "" {
518 t.Fatalf("↓ at draft should be a no-op, got %q", got)
519 }
520}
521
522// TestHistoryDownRestoresUnsentDraft: an unsent draft survives a ↑ into history
523// and is restored when ↓ walks back to the live line.

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
ValueMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected