MCPcopy
hub / github.com/basecamp/once / TestForm_CancelAction

Function TestForm_CancelAction

internal/ui/form_test.go:79–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func TestForm_CancelAction(t *testing.T) {
80 form := NewForm("Done",
81 FormItem{Label: "Field", Field: NewTextField("val")},
82 )
83 cancelled := false
84 form.OnCancel(func(f *Form) tea.Cmd {
85 cancelled = true
86 return nil
87 })
88
89 formPressTab(&form)
90 formPressTab(&form)
91 assert.Equal(t, 2, form.Focused(), "cancel button")
92
93 form, _ = form.Update(keyPressMsg("enter"))
94 assert.True(t, cancelled)
95}
96
97func TestForm_NoFields(t *testing.T) {
98 form := NewForm("Done")

Callers

nothing calls this directly

Calls 8

OnCancelMethod · 0.95
FocusedMethod · 0.95
UpdateMethod · 0.95
NewFormFunction · 0.85
NewTextFieldFunction · 0.85
formPressTabFunction · 0.85
keyPressMsgFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…