(t *testing.T)
| 273 | } |
| 274 | |
| 275 | func TestForm_ValidationFocusesFirstError(t *testing.T) { |
| 276 | form := NewForm("Submit", |
| 277 | FormItem{Label: "First", Field: NewTextField("first")}, |
| 278 | FormItem{Label: "Second", Field: NewTextField("second"), Required: true}, |
| 279 | FormItem{Label: "Third", Field: NewTextField("third"), Required: true}, |
| 280 | ) |
| 281 | form.OnSubmit(func(f *Form) tea.Cmd { return nil }) |
| 282 | |
| 283 | formFocusSubmit(&form) |
| 284 | formPressEnter(&form) |
| 285 | |
| 286 | assert.Equal(t, 1, form.Focused(), "focused on first errored field") |
| 287 | assert.Equal(t, "Second is required", form.Error()) |
| 288 | } |
| 289 | |
| 290 | func TestFormOnRebuild_CalledOnKeyPress(t *testing.T) { |
| 291 | form := NewForm("Done", |
nothing calls this directly
no test coverage detected
searching dependent graphs…