"use strict";

var _FloatingLayer = require("@enact/ui/FloatingLayer");
require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _PopupMenu = require("../PopupMenu");
var _jsxRuntime = require("react/jsx-runtime");
var FloatingLayerController = (0, _FloatingLayer.FloatingLayerDecorator)('div');
describe('PopupMenu specs', function () {
  test('should be rendered opened if open is set to true', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(FloatingLayerController, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PopupMenu.PopupMenu, {
        open: true,
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          children: "popupMenu"
        })
      })
    }));
    var popupMenu = _react.screen.getByText('popupMenu');
    expect(popupMenu).toBeInTheDocument();
  });
  test('should not be rendered if open is set to false', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(FloatingLayerController, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PopupMenu.PopupMenu, {
        open: false,
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          children: "popupMenu"
        })
      })
    }));
    var popup = _react.screen.queryByText('popupMenu');
    expect(popup).toBeNull();
  });
  test('should display correct title', function () {
    var title = 'This is a Popupmenu title';
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(FloatingLayerController, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PopupMenu.PopupMenu, {
        open: true,
        title: title
      })
    }));
    var popupMenuTitle = _react.screen.getByText(title);
    expect(popupMenuTitle).toBeInTheDocument();
    var expected = 'popupMenuTitle';
    var popupMenuTitleElement = _react.screen.getByRole('alert').children.item(0);
    expect(popupMenuTitleElement).toHaveClass(expected);
  });
  test('should apply \'shown\' class when visible with noAnimation', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(FloatingLayerController, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PopupMenu.PopupMenu, {
        noAnimation: true,
        open: true
      })
    }));
    var expected = 'shown';
    var actual = _react.screen.getByRole('alert').parentElement.parentElement;
    expect(actual).toHaveClass(expected);
  });
  test('should apply \'ease-in-out\' class when noAnimation is false', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(FloatingLayerController, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PopupMenu.PopupMenu, {
        noAnimation: false,
        open: true
      })
    }));
    var expected = 'ease-in-out';
    var actual = _react.screen.getByRole('alert').parentElement.parentElement;
    expect(actual).toHaveClass(expected);
  });
  test('should have orientation=horizontal when no orientation is specified', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(FloatingLayerController, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PopupMenu.PopupMenu, {
        open: true
      })
    }));
    var expected = 'horizontal';
    var popupMenu = _react.screen.getByRole('alert');
    expect(popupMenu).toHaveClass(expected);
  });
});