import "@testing-library/jest-dom"; import { render } from "@testing-library/react"; import FormField from "./FormField"; describe("FormField", () => { test("renders children correctly", () => { const { getByText } = render( Test Child , ); expect(getByText("Test Child")).toBeInTheDocument(); }); test("renders error message when error prop is provided", () => { const { getByText } = render( Test Child , ); expect(getByText("Test Error")).toBeInTheDocument(); }); test("applies error class when error prop is provided", () => { const { container } = render( Test Child , ); expect(container.firstChild).toHaveClass("error"); }); test("does not render error message when error prop is not provided", () => { const { queryByText } = render( Test Child , ); expect(queryByText("Test Error")).not.toBeInTheDocument(); }); test("does not apply error class when error prop is not provided", () => { const { container } = render( Test Child , ); expect(container.firstChild).not.toHaveClass("error"); }); });