"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _react = _interopRequireDefault(require("react"));

var _enzyme = require("enzyme");

var _ = _interopRequireDefault(require("./"));

var _Divider = _interopRequireDefault(require("./Divider"));

var _Header = _interopRequireDefault(require("./Header"));

var _Item = _interopRequireDefault(require("./Item"));

describe('Menu', function () {
  it('displays the <Menu> element', function () {
    var node = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Getting Started"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "General"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "General Settings"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Appearance"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Documentation")));
    expect(node.hasClass('Menu')).toBe(true);
  });
  it('displays a <MenuDivider>', function () {
    var node = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Getting Started"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "General"), /*#__PURE__*/_react["default"].createElement(_Divider["default"], null), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Appearance"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Documentation")));
    expect(node.find('.Menu-Divider')).toHaveLength(1);
  });
  it('displays a <MenuHeader>', function () {
    var node = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Header["default"], null, "Support"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Phone"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Chat"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Email")));
    expect(node.find('.Menu-Header')).toHaveLength(1);
  });
  it('displays a blue <Menu-Item>', function () {
    var node = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], {
      color: "blue"
    }, "Blue")));
    expect(node.find('.Menu-Item_blue')).toHaveLength(1);
  });
  it('displays a non-default menu item', function () {
    var node = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], {
      TagName: "div"
    })));
    expect(node.find('div.Menu-Item')).toHaveLength(1);
  });
  it('displays a disabled menu item', function () {
    var node = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], {
      disabled: true
    })));
    expect(node.find('.Menu-Item_link_disabled')).toHaveLength(1);
  });
  it('displays a menu item with an icon', function () {
    var node = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], {
      icon: "fa fa-ban"
    }, "Icon")));
    expect(node.find('i')).toHaveLength(1);
  });
  it('displays a submenu', function () {
    var node = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Colors", /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Red"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Blue")))));
    expect(node.find('.Menu-Item-SubMenu')).toHaveLength(1);
  });
  it('displays a submenu to the left', function () {
    var node = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], {
      openAt: "left"
    }, "Colors", /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Red"), /*#__PURE__*/_react["default"].createElement(_Item["default"], null, "Blue")))));
    expect(node.find('.Menu-Item-SubMenu_left')).toHaveLength(1);
  });
  it('should pass toggle value to callback if callback exists', function () {
    var props = {
      onClick: jest.fn()
    };
    var node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Item["default"], props, "Test")));
    expect(node.find('.Menu-Item')).toHaveLength(1);
    node.find('.Menu-Item').simulate('click');
    expect(props.onClick).toHaveBeenCalled();
  });
});