"use strict";

require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
var _Panel = _interopRequireDefault(require("../Panel"));
var _TabbedPanels = _interopRequireDefault(require("../TabbedPanels"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
describe('TabbedPanels Specs', function () {
  test('should render tabs properly', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_TabbedPanels["default"], {
      orientation: 'vertical',
      tabs: [{
        title: 'Panel1',
        icon: 'netbook'
      }, {
        title: 'Panel2',
        icon: 'aircirculation'
      }],
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Panel["default"], {
        children: "Hello Panel 1"
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Panel["default"], {
        children: "Hello Panel 2"
      })]
    }));
    var firstTab = _react.screen.getByText('Panel1');
    var secondTab = _react.screen.getByText('Panel2');
    expect(firstTab).toBeInTheDocument();
    expect(secondTab).toBeInTheDocument();
  });
  test('should call \'onSelect\' when selecting another tab', /*#__PURE__*/_asyncToGenerator(function* () {
    var spy = jest.fn();
    var user = _userEvent["default"].setup();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_TabbedPanels["default"], {
      onSelect: spy,
      orientation: 'vertical',
      tabs: [{
        title: 'Panel1',
        icon: 'netbook'
      }, {
        title: 'Panel2',
        icon: 'aircirculation'
      }],
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Panel["default"], {
        children: "Hello Panel 1"
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Panel["default"], {
        children: "Hello Panel 2"
      })]
    }));
    var secondTab = _react.screen.getByText('Panel2');
    yield user.click(secondTab);
    expect(spy).toHaveBeenCalled();
  }));
  test('should get content from tabs if there are no children', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_TabbedPanels["default"], {
      orientation: 'vertical',
      tabs: [{
        title: 'Panel1',
        icon: 'netbook',
        view: _Panel["default"],
        viewProps: {
          children: 'Panel 1'
        }
      }]
    }));
    var panel = _react.screen.getByText('Panel 1');
    expect(panel).toBeInTheDocument();
  });
});