test(13-03): add failing tests for Input and Textarea components (RED)

- TestInput_DefaultType: expects type="text" for empty Type
- TestInput_EmailType: expects type="email" for explicit Type
- TestInput_IDFallback: expects id from Name when no ID set
- TestInput_ExplicitID: expects explicit ID to take precedence
- TestTextarea_RendersClass: expects class="ui-textarea"
- TestTextarea_DefaultRows: expects rows="4" for zero Rows
- TestTextarea_ExplicitRows: expects rows="6" for explicit Rows
This commit is contained in:
Arthur Belleville 2026-05-16 13:58:19 +02:00
parent 43ffdae07f
commit ace9f5bdc4
No known key found for this signature in database

View file

@ -226,3 +226,57 @@ func TestBadge_PrimaryVariant(t *testing.T) {
t.Errorf("expected ui-badge-primary in output; got: %s", out) t.Errorf("expected ui-badge-primary in output; got: %s", out)
} }
} }
// Phase 13 Plan 03 — Input and Textarea component tests (TDD RED)
func TestInput_DefaultType(t *testing.T) {
out := render(t, context.Background(), Input(InputProps{Name: "x"}))
if !strings.Contains(out, `type="text"`) {
t.Errorf("expected type=\"text\" for empty Type; got: %s", out)
}
if !strings.Contains(out, `class="ui-input"`) {
t.Errorf("expected class=\"ui-input\"; got: %s", out)
}
}
func TestInput_EmailType(t *testing.T) {
out := render(t, context.Background(), Input(InputProps{Name: "email", Type: "email"}))
if !strings.Contains(out, `type="email"`) {
t.Errorf("expected type=\"email\"; got: %s", out)
}
}
func TestInput_IDFallback(t *testing.T) {
out := render(t, context.Background(), Input(InputProps{Name: "email"}))
if !strings.Contains(out, `id="email"`) {
t.Errorf("expected id=\"email\" (fallback from name); got: %s", out)
}
}
func TestInput_ExplicitID(t *testing.T) {
out := render(t, context.Background(), Input(InputProps{ID: "my-id", Name: "x"}))
if !strings.Contains(out, `id="my-id"`) {
t.Errorf("expected id=\"my-id\"; got: %s", out)
}
}
func TestTextarea_RendersClass(t *testing.T) {
out := render(t, context.Background(), Textarea(TextareaProps{Name: "body"}))
if !strings.Contains(out, `class="ui-textarea"`) {
t.Errorf("expected class=\"ui-textarea\"; got: %s", out)
}
}
func TestTextarea_DefaultRows(t *testing.T) {
out := render(t, context.Background(), Textarea(TextareaProps{Name: "x", Rows: 0}))
if !strings.Contains(out, `rows="4"`) {
t.Errorf("expected rows=\"4\" for zero Rows; got: %s", out)
}
}
func TestTextarea_ExplicitRows(t *testing.T) {
out := render(t, context.Background(), Textarea(TextareaProps{Name: "x", Rows: 6}))
if !strings.Contains(out, `rows="6"`) {
t.Errorf("expected rows=\"6\"; got: %s", out)
}
}