import React__default from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import Popover, { PopoverButton, PopoverContent } from '../index.js';
import '../../defineProperty-CEd-kZQW.js';
import '../../extends-C4cduGrv.js';
import '../../objectWithoutProperties-TXwlfNxG.js';
import 'prop-types';
import '../../portal/index.js';
import '../../slicedToArray-BB-AwwkK.js';
import 'react-dom';
import '../../use-rerender-once/index.js';
import '../../use-force-update/index.js';
import 'classnames';
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 '../../typeof-CgC7Bq6K.js';
import '../../toConsumableArray-dKQYsfpV.js';
import '../../index-qSfOyGhk.js';
import '../../button/button-group.js';
import '../../use-previous/index.js';

describe("Popover", function () {
  it("runs onClose function", function () {
    var handleClose = jest.fn();
    render( /*#__PURE__*/React__default.createElement(Popover, {
      label: "Popover test"
    }, /*#__PURE__*/React__default.createElement(PopoverButton, null, "Toggle"), /*#__PURE__*/React__default.createElement(PopoverContent, {
      onClose: handleClose,
      tabIndex: 0
    }, "Content")));
    var button = screen.getByText("Toggle");
    expect(handleClose).not.toHaveBeenCalled();
    fireEvent.click(button);
    expect(handleClose).not.toHaveBeenCalled();
    fireEvent.click(button);
    expect(handleClose).toHaveBeenCalledTimes(1);
  });
});
