"use strict";

var _react = _interopRequireWildcard(require("react"));
var _testUtilities = require("testUtilities");
var _ = require(".");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
/**
 * @jest-environment jsdom
 */

describe("Tabs states", function () {
  it(" * should render uncontrolled", function () {
    var _renderWithProviders = (0, _testUtilities.renderWithProviders)(/*#__PURE__*/_react["default"].createElement(_.Tabs, null, /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "hi"
      }, "Hello"), /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "Hi again"
      }, "Hello again"), /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "Bye"
      }, "Goodbye"), /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "Bye Bye"
      }, "Fairwell"))),
      container = _renderWithProviders.container,
      getByText = _renderWithProviders.getByText,
      queryByText = _renderWithProviders.queryByText;
    var tabs = container.firstChild;
    expect(tabs).toMatchSnapshot();
    expect(queryByText("Hello")).toBeInTheDocument();
    expect(queryByText("Hello again")).not.toBeInTheDocument();
    expect(queryByText("Goodbye")).not.toBeInTheDocument();
    expect(queryByText("Fairwell")).not.toBeInTheDocument();
    var tab = getByText("Bye Bye");
    _testUtilities.fireEvent.click(tab);
    expect(queryByText("Hello")).not.toBeInTheDocument();
    expect(queryByText("Fairwell")).toBeInTheDocument();
  });
  it(" * should render controlled", function () {
    var onChange = jest.fn();
    var Component = function Component() {
      var _useState = (0, _react.useState)(2),
        selected = _useState[0],
        setSelected = _useState[1];
      return /*#__PURE__*/_react["default"].createElement(_.Tabs, {
        selected: selected,
        onChange: onChange.mockImplementation(function (index) {
          return setSelected(index);
        })
      }, /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "hi"
      }, "Hello"), /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "Hi again"
      }, "Hello again"), /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "Bye"
      }, "Goodbye"), /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "Bye Bye"
      }, "Fairwell"));
    };
    var _renderWithProviders2 = (0, _testUtilities.renderWithProviders)(/*#__PURE__*/_react["default"].createElement(Component, null)),
      queryByText = _renderWithProviders2.queryByText,
      getByText = _renderWithProviders2.getByText;
    expect(queryByText("Hello")).not.toBeInTheDocument();
    expect(queryByText("Hello again")).not.toBeInTheDocument();
    expect(queryByText("Goodbye")).toBeInTheDocument();
    expect(queryByText("Fairwell")).not.toBeInTheDocument();
    var tab = getByText("Hi again");
    _testUtilities.fireEvent.click(tab);
    expect(onChange).toHaveBeenCalledWith(1);
    expect(queryByText("Goodbye")).not.toBeInTheDocument();
    expect(queryByText("Hello again")).toBeInTheDocument();
  });
  it(" * should not allow disabled to be selected", function () {
    var Component = function Component() {
      return /*#__PURE__*/_react["default"].createElement(_.Tabs, null, /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "hi",
        disabled: true
      }, "Hello"), /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "Hi again"
      }, "Hello again"), /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "Bye"
      }, "Goodbye"), /*#__PURE__*/_react["default"].createElement(_.Tab, {
        label: "Bye Bye"
      }, "Fairwell"));
    };
    var _renderWithProviders3 = (0, _testUtilities.renderWithProviders)(/*#__PURE__*/_react["default"].createElement(Component, null)),
      queryByText = _renderWithProviders3.queryByText,
      getByText = _renderWithProviders3.getByText;
    expect(queryByText("Hello")).not.toBeInTheDocument();
    expect(queryByText("Hello again")).toBeInTheDocument();
    var tab = getByText("hi");
    _testUtilities.fireEvent.click(tab);
    expect(queryByText("Hello")).not.toBeInTheDocument();
    expect(queryByText("Hello again")).toBeInTheDocument();
  });
});