"use strict";

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

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

var _enzyme = require("enzyme");

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

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

var _Body = _interopRequireDefault(require("./Body"));

var _Footer = _interopRequireDefault(require("./Footer"));

describe('Modal', function () {
  var node;
  beforeEach(function () {
    node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], null, "Hello, world."));
    node.setState({
      open: true
    });
    var modalRoot = document.createElement('div');
    modalRoot.setAttribute('id', 'modal-root');
    modalRoot.classList.add('ModalWrapper');
    var body = document.querySelector('body');
    body.appendChild(modalRoot);
  });
  afterEach(function () {
    node.unmount();
  });
  it('displays the <Modal> element', function () {
    expect(node.find('.Modal')).toHaveLength(1);
  });
  it('should toggle state.open', function () {
    node.instance().toggle();
    expect(node.state('open')).toBe(false);
    node.instance().toggle(false);
    expect(node.state('open')).toBe(false);
  });
  it('displays the small <Modal>', function () {
    node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], {
      size: "sm"
    }, "Hello, world."));
    expect(node.find('.Modal').hasClass('Modal_sm')).toBe(true);
  });
  it('displays the <Modal> vertically centered', function () {
    node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], {
      verticalCenter: true
    }, "Hello, world."));
    expect(node.find('.Modal').hasClass('Modal_verticalCenter')).toBe(true);
  });
  it('displays the <Modal> with a header, body, and footer', function () {
    node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], null, /*#__PURE__*/_react["default"].createElement(_Header["default"], null), /*#__PURE__*/_react["default"].createElement(_Body["default"], null), /*#__PURE__*/_react["default"].createElement(_Footer["default"], null)));
    expect(node.find('header').hasClass('Modal-Header')).toBe(true);
    expect(node.find('.Modal-Body')).toHaveLength(1);
    expect(node.find('footer').hasClass('Modal-Footer')).toBe(true);
  });
  it('displays the <Modal> with a scrollable body', function () {
    node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], {
      scrollable: true
    }, /*#__PURE__*/_react["default"].createElement(_Header["default"], null), /*#__PURE__*/_react["default"].createElement(_Body["default"], null), /*#__PURE__*/_react["default"].createElement(_Footer["default"], null)));
    expect(node.find('.Modal').hasClass('Modal_scrollable')).toBe(true);
  });
});