"use strict";

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

var _reactDom = _interopRequireDefault(require("react-dom"));

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

var _chai = require("chai");

var _builderHeader = _interopRequireDefault(require("../../builder-header"));

var _iconSettings = _interopRequireDefault(require("../../icon-settings"));

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

/* eslint-disable react/no-render-return-value */
var Simulate = _testUtils.default.Simulate,
    scryRenderedDOMComponentsWithClass = _testUtils.default.scryRenderedDOMComponentsWithClass;
describe('SLDSBuilderHeader: ', function () {
  var clicked;
  var body;

  var setClick = function setClick() {
    clicked = true;
  };

  var renderBuilderHeader = function renderBuilderHeader() {
    body = document.createElement('div');
    document.body.appendChild(body);
    return _reactDom.default.render(_react.default.createElement(_iconSettings.default, {
      iconPath: "/assets/icons"
    }, _react.default.createElement(_builderHeader.default, {
      events: {
        onClickBack: setClick,
        onClickHelp: setClick
      }
    })), body);
  };

  function removeBuilderHeader() {
    _reactDom.default.unmountComponentAtNode(body);

    document.body.removeChild(body);
  }

  describe('Links are clickable', function () {
    var cmp;
    var links;
    beforeEach(function () {
      clicked = false;
      cmp = renderBuilderHeader();
      links = scryRenderedDOMComponentsWithClass(cmp, 'slds-builder-header__item-action');
    });
    afterEach(function () {
      removeBuilderHeader();
    });
    it('triggers when Back link is clicked', function () {
      (0, _chai.expect)(clicked).to.be.false;
      Simulate.click(links[0], {});
      (0, _chai.expect)(clicked).to.be.true;
    });
    it('triggers when Help link is clicked', function () {
      (0, _chai.expect)(clicked).to.be.false;
      Simulate.click(links[1], {});
      (0, _chai.expect)(clicked).to.be.true;
    });
  });
});