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

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

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
ValueMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected