(t *testing.T)
| 88 | } |
| 89 | |
| 90 | func TestTextFieldValidatorValid(t *testing.T) { |
| 91 | b := NewBody() |
| 92 | tf := NewTextField(b).SetText("my secure password") |
| 93 | tf.SetValidator(func() error { |
| 94 | if len(tf.Text()) < 12 { |
| 95 | return errors.New("password must be at least 12 characters") |
| 96 | } |
| 97 | return nil |
| 98 | }) |
| 99 | b.AssertRender(t, "text-field/validator-valid", func() { |
| 100 | tf.SendChange() // trigger validation |
| 101 | }) |
| 102 | } |
| 103 | |
| 104 | func TestTextFieldValidatorInvalid(t *testing.T) { |
| 105 | b := NewBody() |
nothing calls this directly
no test coverage detected