"use strict";

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

var _react = require("react");

var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));

var _Overlay = _interopRequireDefault(require("../Overlay"));

var styles = {
  componentId: 'flcWS',
  template: function template(theme) {
    return "\n\n.overlay__styles__root {\n  position: relative;\n  align-self: center;\n}\n\n.overlay__styles__overlay {\n  position: absolute;\n  top: 0;\n  left: 0;\n  cursor: pointer;\n  z-index: ".concat(theme.overlayZIndex || 'inherit', ";\n\n  height: 100%;\n  width: 100%;\n}\n\n.overlay__styles__overlay:hover {\n    box-sizing: border-box;\n    border-left: ").concat(theme.overlayBarSize || 'inherit', " solid ").concat(theme.overlayBarColor || 'inherit', ";\n  }\n");
  },
  'root': 'overlay__styles__root',
  'overlay': 'overlay__styles__overlay'
};
describe('Overlay', function () {
  var testbed = createTestbed(_Overlay.default);

  var itRendersChildren = function itRendersChildren(testbedInstance) {
    it('renders children', function () {
      var childClassname = 'childElement';
      var childDiv = (0, _react.createElement)('div', {
        className: childClassname
      }, 'child element');
      testbedInstance.render({
        children: childDiv
      });
      var componentWithClass = testbedInstance.findChildrenByClass(childClassname)[0];
      expect(componentWithClass).to.not.be.undefined();
    });
  };

  context('when hideOverlay is true', function () {
    var testbed = createTestbed(_Overlay.default, {
      hideOverlay: true
    });
    itRendersChildren(testbed);
    it('does not render the overlay', function () {
      testbed.render();
      var overlay = testbed.findChildrenByClass(styles.overlay)[0];
      expect(overlay).to.be.undefined();
    });
  });
  context('when hideOverlay is false', function () {
    var testbed = createTestbed(_Overlay.default, {
      hideOverlay: false
    });
    itRendersChildren(testbed);
    it('renders the overlay', function () {
      testbed.render();
      var overlay = testbed.findChildrenByClass(styles.overlay)[0];
      expect(overlay).to.not.be.undefined();
    });
  });
  it('allows for a wrapperClassName', function () {
    var wrapperClassName = 'steve';
    testbed.render({
      wrapperClassName: wrapperClassName
    });
    var componentWithClass = testbed.findChildrenByClass(wrapperClassName)[0];
    expect(componentWithClass).to.not.be.undefined();
  });
  it('allows for an ariaLabel', function () {
    var ariaLabel = 'Example téxt with spaces and Áccents!';
    testbed.render({
      ariaLabel: ariaLabel
    });
    var componentWithAriaLabel = testbed.findChildrenByClass(styles.root)[0];
    expect(componentWithAriaLabel.getAttribute('aria-label')).to.equal(ariaLabel);
  });
  it('handles an onClick callback', function () {
    var clickStub = sinon.stub();
    testbed.render({
      onClick: clickStub
    });

    _testUtils.default.Simulate.click(testbed.findChildrenByClass(styles.overlay)[0]);

    expect(clickStub.called).to.be.true();
  });
  describe('a11y tests', function () {
    it('should meet a11y standards', function (done) {
      testbed.render();
      testbed.checkA11yStandards(done);
    });
  });
});