test(13-04): add failing tests for Modal, EmptyState, Table components (RED)

This commit is contained in:
Arthur Belleville 2026-05-16 14:04:19 +02:00
parent 569c6c7853
commit 4bdb78debf
No known key found for this signature in database

View file

@ -346,3 +346,54 @@ func TestFormField_NoErrorWhenEmpty(t *testing.T) {
t.Errorf("expected NO ui-form-error in output when Error is empty; got: %s", out)
}
}
// Phase 13 Plan 04 — Modal, EmptyState, Table component tests (TDD RED)
func TestModal_RendersBackdropAndPanel(t *testing.T) {
out := render(t, context.Background(), Modal(ModalProps{Title: "Confirm action"}))
for _, want := range []string{"ui-modal-backdrop", "ui-modal-panel"} {
if !strings.Contains(out, want) {
t.Errorf("expected %q in output; got: %s", want, out)
}
}
}
func TestModal_RendersTitle(t *testing.T) {
out := render(t, context.Background(), Modal(ModalProps{Title: "Confirm action"}))
// Title must appear inside a heading element
if !strings.Contains(out, "<h2>") || !strings.Contains(out, "Confirm action") {
t.Errorf("expected <h2> with title text in output; got: %s", out)
}
}
func TestModal_NilBodyOmitted(t *testing.T) {
out := render(t, context.Background(), Modal(ModalProps{Title: "Confirm action"}))
if strings.Contains(out, "ui-modal-body") {
t.Errorf("expected NO ui-modal-body when Body is nil; got: %s", out)
}
}
func TestEmptyState_RendersTitle(t *testing.T) {
out := render(t, context.Background(), EmptyState(EmptyStateProps{Title: "Nothing here yet"}))
for _, want := range []string{"ui-empty-state", "Nothing here yet"} {
if !strings.Contains(out, want) {
t.Errorf("expected %q in output; got: %s", want, out)
}
}
}
func TestEmptyState_NilIconOmitted(t *testing.T) {
out := render(t, context.Background(), EmptyState(EmptyStateProps{Title: "Nothing here yet"}))
if strings.Contains(out, "ui-empty-state-icon") {
t.Errorf("expected NO ui-empty-state-icon when Icon is nil; got: %s", out)
}
}
func TestTable_RendersShell(t *testing.T) {
out := render(t, context.Background(), Table(TableProps{}))
for _, want := range []string{"ui-table-shell", "ui-table"} {
if !strings.Contains(out, want) {
t.Errorf("expected %q in output; got: %s", want, out)
}
}
}