"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = __toESM(require("react"));
var import_react_native = require("@testing-library/react-native");
var import__ = __toESM(require("../.."));
var import_Theme = __toESM(require("../../../Theme"));
var import_RadioGroupContext = __toESM(require("../../RadioGroupContext"));
describe("<RadioGroup />", () => {
  describe("<RadioGroup.Radio />", () => {
    describe("Snapshots", () => {
      it("should match snapshot with default radio", () => {
        const { root, toJSON } = (0, import_react_native.render)(
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.default.Radio, {}) })
        );
        expect(toJSON(root)).toMatchSnapshot();
      });
      it("should match snapshot with disabled radio", () => {
        const { root, toJSON } = (0, import_react_native.render)(
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.default.Radio, { disabled: true }) })
        );
        expect(toJSON(root)).toMatchSnapshot();
      });
      it("should match snapshot with default radio", () => {
        const { root, toJSON } = (0, import_react_native.render)(
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.default.Radio, {}) })
        );
        expect(toJSON(root)).toMatchSnapshot();
      });
      it("should match snapshot with default radio pressed", () => {
        const onChangeMock = jest.fn();
        const { root, getByTestId, toJSON } = (0, import_react_native.render)(
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_RadioGroupContext.default.Provider, { value: { onChange: onChangeMock }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.default.Radio, { testID: "radio" }) }) })
        );
        const radio = getByTestId(/^radio/);
        import_react_native.fireEvent.press(radio);
        expect(toJSON(root)).toMatchSnapshot();
      });
    });
    describe("Props", () => {
      it("checked should be the selectedValue provided from Context", () => {
        const { getAllByTestId } = (0, import_react_native.render)(
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_RadioGroupContext.default.Provider, { value: { selectedValue: "Radio 2" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_Theme.default, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.default.Radio, { testID: "radio", value: "Radio 1" }),
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.default.Radio, { testID: "radio", value: "Radio 2" })
          ] }) })
        );
        const [radio, radio2] = getAllByTestId(/^radio/);
        expect(radio.props.checked).toBe(false);
        expect(radio2.props.checked).toBe(true);
      });
    });
    describe("Events", () => {
      it("should call onchange from Context", () => {
        const onChangeMock = jest.fn();
        const { getByTestId } = (0, import_react_native.render)(
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_RadioGroupContext.default.Provider, { value: { onChange: onChangeMock }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.default.Radio, { testID: "radio" }) }) })
        );
        const radio = getByTestId(/^radio/);
        import_react_native.fireEvent.press(radio);
        expect(onChangeMock).toHaveBeenCalled();
      });
      it("value should be as prop value", () => {
        const onChangeMock = jest.fn();
        const { getByTestId } = (0, import_react_native.render)(
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_RadioGroupContext.default.Provider, { value: { onChange: onChangeMock }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.default.Radio, { value: "radio1", testID: "radio" }) }) })
        );
        const radio = getByTestId(/^radio/);
        import_react_native.fireEvent.press(radio);
        expect(onChangeMock).toHaveBeenCalledWith({
          value: "radio1"
        });
      });
    });
  });
});
