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

Callers

nothing calls this directly

Calls 2

newTestModelFunction · 0.85
UpdateMethod · 0.45

Tested by

no test coverage detected