"use strict";

var _react = _interopRequireDefault(require("react"));
var _testUtilities = require("testUtilities");
var _index = _interopRequireDefault(require("./index"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
var render = function render(props) {
  return (0, _testUtilities.renderWithProviders)(/*#__PURE__*/_react["default"].createElement(_index["default"], _extends({
    label: "character",
    items: [{
      value: "narrator",
      label: "The Narrator"
    }, {
      value: "durgen",
      label: "Tyler Durden"
    }, {
      value: "singer",
      label: "Marla Singer"
    }]
  }, props)));
};
it("renders", function () {
  var _render = render(),
    queryByText = _render.queryByText,
    queryByTestId = _render.queryByTestId;
  expect(queryByText("character")).toBeVisible();
  expect(queryByTestId("drop")).not.toBeInTheDocument();
  expect(queryByText("The Narrator")).not.toBeInTheDocument();
});
it("renders open", function () {
  var _render2 = render(),
    getByText = _render2.getByText,
    queryByTestId = _render2.queryByTestId;
  _testUtilities.fireEvent.click(getByText("character"));
  expect(getByText("character")).toBeVisible();
  expect(queryByTestId("drop")).toBeInTheDocument();
  expect(getByText("The Narrator")).toBeInTheDocument();
});
it("closes on item click", function () {
  var onOpen = jest.fn();
  var onClose = jest.fn();
  var _render3 = render({
      onOpen: onOpen,
      onClose: onClose
    }),
    getByText = _render3.getByText,
    queryByTestId = _render3.queryByTestId;
  _testUtilities.fireEvent.click(getByText("character"));
  expect(onOpen).toBeCalled();
  _testUtilities.fireEvent.click(getByText("Tyler Durden"));
  expect(onClose).toBeCalled();
  expect(queryByTestId("drop")).not.toBeInTheDocument();
});
it("renders controlled", function () {
  var onChange = jest.fn();
  var _render4 = render({
      value: "durgen",
      onChange: onChange,
      label: null
    }),
    getByText = _render4.getByText,
    queryByTestId = _render4.queryByTestId;
  _testUtilities.fireEvent.click(getByText("Tyler Durden"));
  _testUtilities.fireEvent.click(getByText("Marla Singer"));
  expect(onChange).toBeCalledWith("singer");
  expect(queryByTestId("drop")).not.toBeInTheDocument();
});