import { jsx, jsxs } from "react/jsx-runtime";
import React from "react";
import { render } from "@testing-library/react";
import { ThemeProvider, Feedback } from "../..";
function renderWithTheme(ui) {
  return render(ui, { wrapper: ThemeProvider });
}
const title = "Welcome to Yoga";
const description = "Enjoy your membership!";
const caption = "Caption Description here.";
describe("<Feedback />", () => {
  it("should render the title and description", () => {
    const { getByText } = renderWithTheme(
      /* @__PURE__ */ jsx(Feedback, { variant: "success", title, description })
    );
    expect(getByText(title)).toBeTruthy();
    expect(getByText(description)).toBeTruthy();
  });
  it("should render the title children", () => {
    const { getByRole } = renderWithTheme(
      /* @__PURE__ */ jsx(Feedback, { variant: "success", description: "Enjoy your membership!", children: /* @__PURE__ */ jsx(Feedback.Title, { as: "h1", children: title }) })
    );
    expect(getByRole("heading", { name: title })).toBeTruthy();
  });
  it("should render caption children", () => {
    const { getByText } = renderWithTheme(
      /* @__PURE__ */ jsx(Feedback, { variant: "success", title, description, children: /* @__PURE__ */ jsx(Feedback.Caption, { children: caption }) })
    );
    expect(getByText(caption)).toBeTruthy();
  });
  it("should render the buttons", () => {
    const { getByRole } = renderWithTheme(
      /* @__PURE__ */ jsxs(Feedback, { variant: "success", title, description, children: [
        /* @__PURE__ */ jsx(Feedback.PrimaryButton, { children: "Ok" }),
        /* @__PURE__ */ jsx(Feedback.SecondaryButton, { children: "Cancel" })
      ] })
    );
    expect(getByRole("button", { name: "Ok" })).toBeTruthy();
    expect(getByRole("button", { name: "Cancel" })).toBeTruthy();
  });
  it("should render title, description, buttons and caption", () => {
    const { getByText, getByRole } = renderWithTheme(
      /* @__PURE__ */ jsxs(Feedback, { variant: "success", description: "Enjoy your membership!", children: [
        /* @__PURE__ */ jsx(Feedback.Caption, { children: caption }),
        /* @__PURE__ */ jsx(Feedback.PrimaryButton, { children: "Ok" }),
        /* @__PURE__ */ jsx(Feedback.SecondaryButton, { children: "Cancel" })
      ] })
    );
    expect(getByText(caption)).toBeTruthy();
    expect(getByRole("button", { name: "Ok" })).toBeTruthy();
    expect(getByRole("button", { name: "Cancel" })).toBeTruthy();
  });
  it("should render correctly when not centered vertically", () => {
    const { baseElement } = renderWithTheme(
      /* @__PURE__ */ jsx(
        Feedback,
        {
          variant: "success",
          title,
          description,
          center: false
        }
      )
    );
    expect(baseElement).toMatchSnapshot();
  });
  it("should render the icon for success variant", () => {
    const { getByTestId } = renderWithTheme(
      /* @__PURE__ */ jsx(Feedback, { variant: "success", title, description })
    );
    expect(getByTestId("feedback-icon-success")).toMatchSnapshot();
  });
  it("should render the icon for informative variant", () => {
    const { getByTestId } = renderWithTheme(
      /* @__PURE__ */ jsx(
        Feedback,
        {
          variant: "informative",
          title,
          description
        }
      )
    );
    expect(getByTestId("feedback-icon-informative")).toMatchSnapshot();
  });
  it("should render the icon for attention variant", () => {
    const { getByTestId } = renderWithTheme(
      /* @__PURE__ */ jsx(Feedback, { variant: "attention", title, description })
    );
    expect(getByTestId("feedback-icon-attention")).toMatchSnapshot();
  });
  it("should render the icon for delayed variant", () => {
    const { getByTestId } = renderWithTheme(
      /* @__PURE__ */ jsx(Feedback, { variant: "delayed", title, description })
    );
    expect(getByTestId("feedback-icon-delayed")).toMatchSnapshot();
  });
  it("should render multiple paragraphs when description is an array", () => {
    const multiDescription = [
      "First paragraph of the feedback description.",
      "Second paragraph providing extra context.",
      "Third paragraph with final details."
    ];
    const { getByText } = renderWithTheme(
      /* @__PURE__ */ jsx(
        Feedback,
        {
          variant: "success",
          title,
          description: multiDescription
        }
      )
    );
    multiDescription.forEach((text) => {
      expect(getByText(text)).toBeTruthy();
    });
  });
});
