TestNonCtrlCKeypressResetsArming: once arming is live, pressing anything other than Ctrl+C clears the arm so the next idle Ctrl+C re-arms cleanly (no accidental quits).
(t *testing.T)
| 213 | // other than Ctrl+C clears the arm so the next idle Ctrl+C re-arms cleanly |
| 214 | // (no accidental quits). |
| 215 | func TestNonCtrlCKeypressResetsArming(t *testing.T) { |
| 216 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 217 | first, _ := m.Update(tea.KeyMsg{Type: tea.KeyCtrlC}) |
| 218 | fm := first.(Model) |
| 219 | if fm.quitArmedAt.IsZero() { |
| 220 | t.Fatal("precondition: quit should be armed") |
| 221 | } |
| 222 | typed, _ := fm.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'x'}}) |
| 223 | if !typed.(Model).quitArmedAt.IsZero() { |
| 224 | t.Fatal("any other keystroke must clear arming") |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | // typeInto feeds text one rune at a time, as a keyboard would, exercising the |
| 229 | // refreshSuggest hook on the KeyRunes fall-through. |
nothing calls this directly
no test coverage detected