26 lines
1.2 KiB
TypeScript
26 lines
1.2 KiB
TypeScript
// @vitest-environment jsdom
|
|
import "@testing-library/jest-dom/vitest";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it } from "vitest";
|
|
import { EmptyState } from "./index";
|
|
|
|
describe("EmptyState wrapper", () => {
|
|
it("renders the action slot button", () => {
|
|
render(<EmptyState title="Nothing here" body="Add something" action={<button type="button">Create</button>} />);
|
|
expect(screen.getByRole("button", { name: "Create" })).toBeInTheDocument();
|
|
});
|
|
|
|
// Regression guard: the wrapper once merged `[&_button]:hidden` into the root
|
|
// (a workaround for a since-removed hardcoded CTA in the synced component),
|
|
// which display:none'd every action button screens pass in.
|
|
it("does not hide descendant buttons via a blanket class", () => {
|
|
const { container } = render(<EmptyState title="Nothing here" action={<button type="button">Create</button>} />);
|
|
expect(container.innerHTML).not.toContain("[&_button]:hidden");
|
|
});
|
|
|
|
it("still forwards a caller-provided className", () => {
|
|
const { container } = render(<EmptyState title="Nothing here" className="custom-class" />);
|
|
expect(container.firstElementChild).toHaveClass("custom-class");
|
|
});
|
|
});
|