diff --git a/backend/internal/web/ui/ui_test.go b/backend/internal/web/ui/ui_test.go index 4125007..468a90d 100644 --- a/backend/internal/web/ui/ui_test.go +++ b/backend/internal/web/ui/ui_test.go @@ -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) + } +}