"use strict";

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

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

var _index = _interopRequireDefault(require("../index"));

var styles = {
  componentId: 'epout',
  template: function template(theme) {
    return "\n\n.WarningWrapper__styles__alert {\n  padding-bottom: ".concat(theme.alertPadding || 'inherit', ";\n  z-index: ").concat(theme.alertZIndex || 'inherit', ";\n  position: inherit;\n}\n\n.WarningWrapper__styles__alertContent {\n  display: block;\n}\n\n.WarningWrapper__styles__container {\n  position: relative;\n  padding: ").concat(theme.containerPadding || 'inherit', ";\n}\n\n.WarningWrapper__styles__disabledChildren {\n  background-color: ").concat(theme.disabledChildrenBackgroundColor || 'inherit', ";\n  opacity: ").concat(theme.disabledChildrenOpacity || 'inherit', ";\n  position: absolute;\n  z-index: ").concat(theme.disabledChildrenZIndex || 'inherit', ";\n  top: 0;\n  bottom: 0;\n  left: 0;\n  right: 0;\n}\n");
  },
  'alert': 'WarningWrapper__styles__alert',
  'alertContent': 'WarningWrapper__styles__alertContent',
  'container': 'WarningWrapper__styles__container',
  'disabledChildren': 'WarningWrapper__styles__disabledChildren'
};
describe('Item Warning Wrapper', function () {
  var cancelActionCallback = sinon.stub();
  var defaultActionCallback = sinon.stub();
  var testbed = createTestbed(_index.default, {
    cancelActionCallback: cancelActionCallback,
    children: _react.default.createElement("button", null),
    defaultActionCallback: defaultActionCallback,
    description: 'description',
    hideActions: true,
    showAlert: true
  });
  describe('#render', function () {
    it('renders the wrapper', function () {
      var shallowTestbed = testbed.renderShallowly();
      var alert = shallowTestbed.find('Alert');
      expect(alert).to.have.length(1);
    });
    it('renders the children content', function () {
      var shallowTestbed = testbed.renderShallowly();
      var button = shallowTestbed.find('button');
      expect(button).to.have.length(1);
    });
    it('renders the action buttons', function () {
      var shallowTestbed = testbed.renderShallowly({
        hideActions: false
      });
      var button = shallowTestbed.find('Button');
      expect(button).to.have.length(2);
    });
    it('hides children', function () {
      var shallowTestbed = testbed.renderShallowly({
        disableChildren: true
      });
      var overlay = shallowTestbed.find(styles.disabledChildren);
      expect(overlay).to.not.be.undefined();
    });
    it('hides alert', function () {
      var shallowTestbed = testbed.renderShallowly({
        showAlert: false
      });
      var alert = shallowTestbed.find('Alert');
      expect(alert).to.have.length(0);
    });
    it('sets focus on first interactive element', function () {
      testbed.render({
        hideActions: false
      });
      expect(document.activeElement.tagName).to.equal('BUTTON');
    });
  });
});