go-htmx-gsd #1

Merged
arthur merged 558 commits from go-htmx-gsd into main 2026-05-23 15:16:44 +00:00
Showing only changes of commit ace9f5bdc4 - Show all commits

View file

@ -226,3 +226,57 @@ func TestBadge_PrimaryVariant(t *testing.T) {
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)
}
}