import { _ as _slicedToArray } from '../../slicedToArray-BB-AwwkK.js';
import React__default, { useState } from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import '@testing-library/jest-dom/extend-expect';
import Modal from '../index.js';
import Action from '../action.js';
import '../../extends-C4cduGrv.js';
import '../../defineProperty-CEd-kZQW.js';
import '../../objectWithoutProperties-TXwlfNxG.js';
import 'prop-types';
import 'classnames';
import '../../dialog.esm-C1hoFD2p.js';
import '../../typeof-CgC7Bq6K.js';
import '../../portal.esm-CuKGPwhL.js';
import '../../utils.esm-CKyxlHOy.js';
import '../../warning-s9zGJbnw.js';
import 'react-dom';
import '../../setPrototypeOf-Bchah3-D.js';
import '../../loading-animation/index.js';
import '../../button/index.js';
import '@reach/visually-hidden';
import '../../ck-icon/index.js';
import '../../ck-icon/assets/icon-map/index.js';
import '../../icon/index.js';
import '@fortawesome/react-fontawesome';
import '../../icon/icons.js';
import '../../icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/pro-solid-svg-icons';
import '@fortawesome/pro-light-svg-icons';
import '@fortawesome/free-brands-svg-icons';
import '../../floating-ui.react-cWPyyUrN.js';
import '../../toConsumableArray-dKQYsfpV.js';
import '../../index-qSfOyGhk.js';
import '../../button/button-group.js';
import '../../portal/index.js';
import '../../use-rerender-once/index.js';
import '../../use-force-update/index.js';
import 'framer-motion';
import '../confirm-modal.js';
import '../../auto-id.esm-Cly76abB.js';
import '../confirm.js';
import '../title-bar.js';

describe("Modal", function () {
  test("actions render", function () {
    render( /*#__PURE__*/React__default.createElement(Modal, {
      label: "Label",
      onClose: function onClose() {}
    }, "Content", /*#__PURE__*/React__default.createElement(Action, null, "Save"), /*#__PURE__*/React__default.createElement(Action, null, "Destroy")));
    expect(screen.getByText("Save")).toBeInTheDocument();
    expect(screen.getByText("Destroy")).toBeInTheDocument();
  });
  test("nested actions", function () {
    render( /*#__PURE__*/React__default.createElement(Modal, {
      label: "Label",
      onClose: function onClose() {}
    }, "Content", /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(Action, null, "Save"), /*#__PURE__*/React__default.createElement(Action, null, "Destroy"))));
    expect(screen.getByText("Save")).toBeInTheDocument();
    expect(screen.getByText("Destroy")).toBeInTheDocument();
    var container = screen.getByTestId("actions");
    expect(container.contains(screen.getByText("Save"))).toBe(true);
    expect(container.contains(screen.getByText("Destroy"))).toBe(true);
  });
  test("no actions doesn't render container", function () {
    render( /*#__PURE__*/React__default.createElement(Modal, {
      label: "Label",
      onClose: function onClose() {}
    }, "Content"));
    expect(screen.queryByTestId("actions")).not.toBeInTheDocument();
  });
  test("handles changing props", function () {
    var TestModal = function TestModal() {
      var _useState = useState("primary"),
          _useState2 = _slicedToArray(_useState, 2),
          token = _useState2[0],
          setToken = _useState2[1];

      return /*#__PURE__*/React__default.createElement(Modal, {
        label: "Label",
        onClose: function onClose() {}
      }, "Content", /*#__PURE__*/React__default.createElement(Action, {
        is: token,
        onClick: function onClick() {
          return setToken("secondary");
        }
      }, "Change Color"), /*#__PURE__*/React__default.createElement(Action, null, "Destroy"));
    };

    render( /*#__PURE__*/React__default.createElement(TestModal, null));
    expect(screen.getByText("Change Color").className.includes("bg-red-500")).toBe(true);
    userEvent.click(screen.getByText("Change Color"));
    expect(screen.getByText("Change Color").className.includes("bg-red-500")).toBe(false);
  });
});
