import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { fireEvent, render, screen } from "@testing-library/react";
import { FormLabel } from "./form-label.js";
describe("FormLabel Component", () => {
    it("should match snapshot", () => {
        const { asFragment } = render(_jsx(FormLabel, { "data-testid": "form-label", children: "label" }));
        expect(asFragment()).toMatchSnapshot();
    });
    it("should display the correct label text", () => {
        render(_jsx(FormLabel, { children: "Test Label" }));
        expect(screen.getByText("Test Label")).toBeInTheDocument();
    });
    it("should forward the htmlFor attribute", () => {
        render(_jsx(FormLabel, { htmlFor: "test-input", children: "Label" }));
        const label = screen.getByText("Label");
        expect(label).toHaveAttribute("for", "test-input");
    });
    it("should render children as expected", () => {
        render(_jsxs(FormLabel, { children: ["Label ", _jsx("span", { "data-testid": "child-element", children: "Child" })] }));
        expect(screen.getByText("Label")).toBeInTheDocument();
        expect(screen.getByTestId("child-element")).toBeInTheDocument();
    });
    it("should handle click events", () => {
        const handleClick = vi.fn();
        render(_jsx(FormLabel, { onClick: handleClick, children: "Clickable Label" }));
        const label = screen.getByText("Clickable Label");
        fireEvent.click(label);
        expect(handleClick).toHaveBeenCalledTimes(1);
    });
    it("should display an asterisk when required", () => {
        render(_jsx(FormLabel, { required: true, children: "Required Label" }));
        const asterisk = screen.getByText("*");
        expect(asterisk).toBeInTheDocument();
    });
    it("should have not-allowed cursor when disabled", () => {
        render(_jsx(FormLabel, { disabled: true, children: "Disabled Label" }));
        const label = screen.getByText("Disabled Label");
        expect(label).toHaveClass("cursor-not-allowed");
    });
    it("should display an icon when description is provided", () => {
        render(_jsx(FormLabel, { description: "This is a description", children: "Label with Description" }));
        const icon = screen.getByRole("button");
        expect(icon).toBeInTheDocument();
        // Check that the SVG is rendered with correct dimensions
        const svg = icon.querySelector("svg");
        expect(svg).toHaveStyle({ width: "16px", height: "16px" });
    });
    it("should apply custom styles", () => {
        const customStyle = { color: "red", fontWeight: "bold" };
        render(_jsx(FormLabel, { "data-testid": "styled-label", style: customStyle, children: "Styled Label" }));
        const label = screen.getByTestId("styled-label");
        expect(label.style.color).toBe(customStyle.color);
        expect(label.style.fontWeight).toBe(customStyle.fontWeight);
    });
});
//# sourceMappingURL=form-label.test.js.map