TestHistoryUpDownReplayLastSubmission: ↑ on first-line replaces textarea with the most recent submitted line; ↓ steps back toward the draft.
(t *testing.T)
| 489 | func 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. |
| 522 | func TestHistoryDownRestoresUnsentDraft(t *testing.T) { |
| 523 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
nothing calls this directly
no test coverage detected