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

Function TestForm_SubmitAction

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

Source from the content-addressed store, hash-verified

60}
61
62func TestForm_SubmitAction(t *testing.T) {
63 form := NewForm("Done",
64 FormItem{Label: "Field", Field: NewTextField("val")},
65 )
66 submitted := false
67 form.OnSubmit(func(f *Form) tea.Cmd {
68 submitted = true
69 return nil
70 })
71
72 formPressTab(&form)
73 assert.Equal(t, 1, form.Focused(), "submit button")
74
75 form, _ = form.Update(keyPressMsg("enter"))
76 assert.True(t, submitted)
77}
78
79func TestForm_CancelAction(t *testing.T) {
80 form := NewForm("Done",

Callers

nothing calls this directly

Calls 8

OnSubmitMethod · 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…