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

Function TestForm_ValidationNonRequiredDoesNotBlock

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

Source from the content-addressed store, hash-verified

237}
238
239func TestForm_ValidationNonRequiredDoesNotBlock(t *testing.T) {
240 form := NewForm("Submit",
241 FormItem{Label: "Optional", Field: NewTextField("opt")},
242 FormItem{Label: "Required", Field: NewTextField("req"), Required: true},
243 )
244 submitted := false
245 form.OnSubmit(func(f *Form) tea.Cmd {
246 submitted = true
247 return nil
248 })
249
250 formPressTab(&form) // focus second field
251 formTypeText(&form, "filled")
252 formFocusSubmit(&form)
253 formPressEnter(&form)
254
255 assert.True(t, submitted)
256 assert.False(t, form.HasError())
257}
258
259func TestForm_ValidationOnClickSubmit(t *testing.T) {
260 form := NewForm("Submit",

Callers

nothing calls this directly

Calls 8

OnSubmitMethod · 0.95
HasErrorMethod · 0.95
NewFormFunction · 0.85
NewTextFieldFunction · 0.85
formPressTabFunction · 0.85
formTypeTextFunction · 0.85
formFocusSubmitFunction · 0.85
formPressEnterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…