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

Function TestCtrlCIdleArmsThenQuits

internal/tui/tui_test.go:142–159  ·  view source on GitHub ↗

TestCtrlCIdleArmsThenQuits: first Ctrl+C in idle arms the status bar and returns a Tick cmd; second Ctrl+C before the window expires returns Quit.

(t *testing.T)

Source from the content-addressed store, hash-verified

140// TestCtrlCIdleArmsThenQuits: first Ctrl+C in idle arms the status bar and
141// returns a Tick cmd; second Ctrl+C before the window expires returns Quit.
142func TestCtrlCIdleArmsThenQuits(t *testing.T) {
143 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
144 first, cmd1 := m.Update(tea.KeyMsg{Type: tea.KeyCtrlC})
145 fm := first.(Model)
146 if fm.quitArmedAt.IsZero() {
147 t.Fatal("first Ctrl+C should arm quitArmedAt")
148 }
149 if !strings.Contains(fm.renderStatusBar(), "press Ctrl+C again") {
150 t.Fatalf("status bar should show arming hint, got: %s", fm.renderStatusBar())
151 }
152 if cmd1 == nil {
153 t.Fatal("first press should return tea.Tick cmd")
154 }
155 _, cmd2 := fm.Update(tea.KeyMsg{Type: tea.KeyCtrlC})
156 if cmd2 == nil {
157 t.Fatal("second Ctrl+C should return tea.Quit cmd")
158 }
159}
160
161// TestCtrlCPopoverClosesInsteadOfQuitting: with the popover open and no
162// in-flight op, Ctrl+C dismisses the popover and does not arm quit.

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
renderStatusBarMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected