"use strict";

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _enzyme = require("enzyme");

var _Popup = require("../Popup");

var _Popup2 = _interopRequireDefault(require("../Popup.less"));

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

describe('Popup specs', function () {
  var options = {
    context: {
      getFloatingLayer: function getFloatingLayer() {
        return document.getElementById('floatLayer');
      }
    },
    childContextTypes: {
      getFloatingLayer: _propTypes.default.func
    }
  };
  beforeEach(function () {
    var div = document.createElement('div');
    div.setAttribute('id', 'floatLayer');
    document.body.appendChild(div);
  });
  afterEach(function () {
    var div = document.getElementById('floatLayer');
    document.body.removeChild(div);
  });
  it('should be rendered opened if open is set to true', function () {
    var popup = (0, _enzyme.mount)(_react.default.createElement(_Popup.Popup, {
      open: true
    }, _react.default.createElement("div", null, "popup")), options);
    var expected = true;
    var actual = popup.find('FloatingLayer').prop('open');
    expect(actual).to.equal(expected);
  });
  it('should not be rendered if open is set to false', function () {
    var popup = (0, _enzyme.mount)(_react.default.createElement(_Popup.Popup, null, _react.default.createElement("div", null, "popup")), options);
    var expected = false;
    var actual = popup.find('FloatingLayer').prop('open');
    expect(actual).to.equal(expected);
  });
  it('should set popup close button "aria-label" to closeButtonAriaLabel', function () {
    var label = 'custom close button label';
    var popup = (0, _enzyme.mount)(_react.default.createElement(_Popup.Popup, {
      open: true,
      showCloseButton: true,
      closeButtonAriaLabel: label
    }, _react.default.createElement("div", null, "popup")), options);
    var expected = label;
    var actual = popup.find('IconButton').prop('aria-label');
    expect(actual).to.equal(expected);
  });
  it('should set role to alert by default', function () {
    var popup = (0, _enzyme.shallow)(_react.default.createElement(_Popup.PopupBase, null, _react.default.createElement("div", null, "popup")));
    var expected = 'alert';
    var actual = popup.find(".".concat(_Popup2.default.popup)).prop('role');
    expect(actual).to.equal(expected);
  });
  it('should allow role to be overridden', function () {
    var popup = (0, _enzyme.shallow)(_react.default.createElement(_Popup.PopupBase, {
      role: "dialog"
    }, _react.default.createElement("div", null, "popup")));
    var expected = 'dialog';
    var actual = popup.find(".".concat(_Popup2.default.popup)).prop('role');
    expect(actual).to.equal(expected);
  });
});