import { _ as _slicedToArray } from '../../slicedToArray-BB-AwwkK.js';
import { _ as _asyncToGenerator, r as regenerator } from '../../index-qSfOyGhk.js';
import React__default, { useState } from 'react';
import { render, screen, act } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Modal from '../index.js';
import Action from '../action.js';
import '../../typeof-CgC7Bq6K.js';
import '../../extends-C4cduGrv.js';
import '../../defineProperty-CEd-kZQW.js';
import '../../objectWithoutProperties-TXwlfNxG.js';
import 'prop-types';
import 'classnames';
import '../../dialog.esm-CUULjZBh.js';
import '../../portal.esm-D9LQ40g_.js';
import '../../utils.esm-BKUEBdyY.js';
import '../../warning-s9zGJbnw.js';
import 'react-dom';
import '../../setPrototypeOf-Bchah3-D.js';
import '../../loading-animation/index.js';
import '../../index-CMfVNfTW.js';
import '../../toConsumableArray-dKQYsfpV.js';
import '../../icon/assets/icon-map/index.js';
import '../../social-icon/index.js';
import '@fortawesome/react-fontawesome';
import '../../social-icon/icons.js';
import '../../social-icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/free-solid-svg-icons';
import '@fortawesome/free-brands-svg-icons';
import '../../tooltip/index.js';
import '../../auto-id.esm-CjaDlg7r.js';
import '@reach/visually-hidden';
import '../../portal/index.js';
import '../../use-rerender-once/index.js';
import '../../use-force-update/index.js';
import '../../button/button-group.js';
import '../../inject-css-BqVV5N0s.js';
import 'framer-motion';
import '../confirm-modal.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", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
    var TestModal;
    return regenerator.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            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-black")).toBe(true);
            _context.next = 5;
            return act(function () {
              return userEvent.click(screen.getByText("Change Color"));
            });

          case 5:
            expect(screen.getByText("Change Color").className.includes("bg-black")).toBe(false);

          case 6:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  })));
});
