"use strict";

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

var _enzyme = _interopRequireWildcard(require("enzyme"));

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

var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-16"));

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

_enzyme.default.configure({
  adapter: new _enzymeAdapterReact.default()
});

describe('SideNav', function () {
  test('should render', function () {
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.SideNav, {
      onClick: function onClick() {},
      userMenu: _react.default.createElement("div", null)
    }));
    wrapper.update();
    expect(wrapper.find('.vs-sidenav')).toHaveLength(1);
  });
  test('should render active', function () {
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.SideNav, {
      onClick: function onClick() {},
      collapsed: false
    }));
    wrapper.update();
    expect(wrapper.find('.vs-sidenav.active')).toHaveLength(1);
  });
  test('should render collapsed', function () {
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.SideNav, {
      onClick: function onClick() {},
      collapsed: true
    }));
    wrapper.update();
    expect(wrapper.find('.vs-sidenav.collapsed')).toHaveLength(1);
  });
  test('should give default home page if no homeLink is given', function () {
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.SideNav, {
      onClick: function onClick() {},
      collapsed: true
    }));
    wrapper.update();
    expect(wrapper.find('a.vs-sidenav-container-row').props().href).toEqual('/');
  });
  test('should correctly set the homeLink if one is given', function () {
    var homeLink = 'somewhere/else';
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.SideNav, {
      onClick: function onClick() {},
      collapsed: true,
      homeLink: homeLink
    }));
    wrapper.update();
    expect(wrapper.find('a.vs-sidenav-container-row').props().href).toEqual(homeLink);
  });
  describe('Header', function () {
    test('should render with children', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.Header, null, _react.default.createElement("div", {
        className: "dummy"
      }, "something")));
      wrapper.update();
      expect(wrapper.find('.vs-sidenav-entry')).toHaveLength(1);
      expect(wrapper.find('.vs-sidenav-entry').children()).toHaveLength(1);
    });
  });
  describe('LinkGroup', function () {
    test('should render with default icon if none is given', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.LinkGroup, {
        label: "nothing",
        onClick: function onClick() {},
        toggleSideNav: function toggleSideNav() {}
      }));
      wrapper.update();
      expect(wrapper.find('.vs-sidenav-entry')).toHaveLength(1);
      expect(wrapper.find('.fa-stack.vs-stacked-icon')).toHaveLength(1);
    });
    test('should render with passed in icon', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.LinkGroup, {
        label: "nothing",
        icon: _react.default.createElement("div", {
          className: "fake-icon"
        }),
        onClick: function onClick() {},
        toggleSideNav: function toggleSideNav() {}
      }));
      wrapper.update();
      expect(wrapper.find('.fake-icon')).toHaveLength(1);
    });
  });
  describe('Link', function () {
    test('should render with children and default Icon', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_.Link, {
        inLinkGroup: false
      }, _react.default.createElement("a", {
        href: "mock link for React Router"
      }, _react.default.createElement("span", null, "Label without Text"))));
      wrapper.update();
      expect(wrapper.find('.vs-sidenav-entry')).toHaveLength(1);
    });
  });
  describe('ToggleIcon', function () {
    test('should render', function () {
      var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_.ToggleIcon, null));
      wrapper.update();
      expect(wrapper.find('.vs-sidenav-toggle-icon')).toHaveLength(1);
    });
  });
  describe('UserIcon', function () {
    test('should render first and last', function () {
      var wrapper = (0, _enzyme.shallow)(_react.default.createElement(_.UserIcon, {
        firstInitial: "A",
        lastInitial: "B"
      }));
      wrapper.update();
      expect(wrapper.text()).toEqual('AB');
    });
  });
});