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

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
renderStatusBarMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected