"use strict";

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

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

var _lodash = _interopRequireDefault(require("lodash.assign"));

var _chai = _interopRequireDefault(require("chai"));

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

var _buttonStateful = _interopRequireDefault(require("../../button-stateful"));

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

_chai.default.should();

describe('Button Stateful: ', function () {
  // Base defaults
  var requiredProps = {
    assistiveText: {
      icon: 'like'
    },
    iconName: 'like',
    iconSize: 'large',
    variant: 'icon'
  }; // Setup and takedown

  var renderButton = function renderButton(instance) {
    return function renderButtonFunction() {
      this.dom = document.createElement('div');
      document.body.appendChild(this.dom);
      this.component = _reactDom.default.render(_react.default.createElement(_iconSettings.default, {
        iconPath: "/assets/icons"
      }, instance), this.dom);
    };
  };

  function removeButton() {
    _reactDom.default.unmountComponentAtNode(this.dom);

    document.body.removeChild(this.dom);
  }

  var getButton = function getButton(dom) {
    return dom.querySelector('.slds-button');
  }; // Tests


  describe('Default Structure', function () {
    beforeEach(renderButton(_react.default.createElement(_buttonStateful.default, requiredProps)));
    afterEach(removeButton);
    it('button exists - is not undefined', function () {
      var button = getButton(this.dom);
      button.should.not.be.undefined;
    });
    it('if no active prop, is not active', function () {
      var button = getButton(this.dom);
      button.className.should.include('slds-not-selected');
    });
  });
  describe('External active props works', function () {
    var propsWithActive = (0, _lodash.default)(requiredProps, {
      active: true
    });
    beforeEach(renderButton(_react.default.createElement(_buttonStateful.default, propsWithActive)));
    afterEach(removeButton);
    it('renders active prop', function () {
      var button = getButton(this.dom);
      button.className.should.include('slds-is-selected');
    });
  }); // TODO: Write more tests for custom renderers
});