TestHistoryDownRestoresUnsentDraft: an unsent draft survives a ↑ into history and is restored when ↓ walks back to the live line.
(t *testing.T)
| 522 | // TestHistoryDownRestoresUnsentDraft: an unsent draft survives a ↑ into history |
| 523 | // and is restored when ↓ walks back to the live line. |
| 524 | func 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. |
nothing calls this directly
no test coverage detected