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); }
import React from "react";
import { renderWithProviders, fireEvent } from "testUtilities";
import Menu from "./index";
var render = function render(props) {
  return renderWithProviders(/*#__PURE__*/React.createElement(Menu, _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;
  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;
  fireEvent.click(getByText("character"));
  expect(onOpen).toBeCalled();
  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;
  fireEvent.click(getByText("Tyler Durden"));
  fireEvent.click(getByText("Marla Singer"));
  expect(onChange).toBeCalledWith("singer");
  expect(queryByTestId("drop")).not.toBeInTheDocument();
});