"use strict";

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

var _enzyme = require("enzyme");

var _sinon = _interopRequireDefault(require("sinon"));

var _Button = _interopRequireDefault(require("../Button"));

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

describe('Button', function () {
  it('should render with button text upper-cased', function () {
    var msg = 'Hello Button!';
    var button = (0, _enzyme.mount)(_react.default.createElement(_Button.default, null, msg));
    var expected = msg.toUpperCase();
    var actual = button.text();
    expect(actual).to.equal(expected);
  });
  it('should have \'disabled\' HTML attribute when \'disabled\' prop is provided', function () {
    var button = (0, _enzyme.mount)(_react.default.createElement(_Button.default, {
      disabled: true
    }, "I am a disabled Button"));
    var expected = true;
    var actual = button.find('div').at(0).prop('disabled');
    expect(actual).to.equal(expected);
  });
  describe('events', function () {
    it('should call onClick when not disabled', function () {
      var handleClick = _sinon.default.spy();

      var subject = (0, _enzyme.mount)(_react.default.createElement(_Button.default, {
        onClick: handleClick
      }, "I am a disabled Button"));
      subject.simulate('click');
      var expected = true;
      var actual = handleClick.called;
      expect(actual).to.equal(expected);
    });
    it('should not call onClick when disabled', function () {
      var handleClick = _sinon.default.spy();

      var subject = (0, _enzyme.mount)(_react.default.createElement(_Button.default, {
        disabled: true,
        onClick: handleClick
      }, "I am a disabled Button"));
      subject.simulate('click');
      var expected = false;
      var actual = handleClick.called;
      expect(actual).to.equal(expected);
    });
  });
});