import { jsx, jsxs } from "react/jsx-runtime";
import React from "react";
import { render, fireEvent } from "@testing-library/react-native";
import RadioGroup from "..";
import ThemeProvider from "../../Theme";
describe("<RadioGroup />", () => {
  describe("Snapshots", () => {
    it("should match snapshot with radio button as children", () => {
      const { root, getAllByText, toJSON } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsxs(RadioGroup, { children: [
          /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 1" }),
          /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 2" }),
          /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 3" })
        ] }) })
      );
      expect(toJSON(root)).toMatchSnapshot();
      expect(getAllByText(/^Option/)).toHaveLength(3);
    });
    it("should match snapshot with small radios", () => {
      const { root, toJSON } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsxs(RadioGroup, { small: true, children: [
          /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 1" }),
          /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 2" }),
          /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 3" })
        ] }) })
      );
      expect(toJSON(root)).toMatchSnapshot();
    });
    it("should has setted the selected value", () => {
      const { toJSON, getByText } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsxs(RadioGroup, { selectedValue: "Option 2", children: [
          /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 1" }),
          /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 2" }),
          /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 3" })
        ] }) })
      );
      expect(toJSON()).toMatchSnapshot();
      expect(getByText("Option 2").props.checked).toBe(true);
    });
  });
});
describe("Events", () => {
  it("should set the onchange for its children", () => {
    const onChangeMock = jest.fn();
    const { getByText } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsxs(RadioGroup, { onChange: onChangeMock, children: [
        /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 1" }),
        /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 2" }),
        /* @__PURE__ */ jsx(RadioGroup.Button, { children: "Option 3" })
      ] }) })
    );
    const firstOption = getByText("Option 1");
    fireEvent.press(firstOption);
    expect(onChangeMock).toHaveBeenCalled();
  });
});
