MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestNonCtrlCKeypressResetsArming

Function TestNonCtrlCKeypressResetsArming

internal/tui/tui_test.go:215–226  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

213// other than Ctrl+C clears the arm so the next idle Ctrl+C re-arms cleanly
214// (no accidental quits).
215func 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.

Callers

nothing calls this directly

Calls 2

newTestModelFunction · 0.85
UpdateMethod · 0.45

Tested by

no test coverage detected