"use strict";

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

var uut = _interopRequireWildcard(require("../index"));

var _enzyme = _interopRequireWildcard(require("enzyme"));

var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-16"));

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

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

_enzyme.default.configure({
  adapter: new _enzymeAdapterReact.default()
});

describe('TriStateCheckbox', function () {
  it('should render unselected state', function () {
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(uut.TriStateCheckbox, {
      value: 0
    }));
    var checkbox = wrapper.find('input[type="checkbox"]').getDOMNode();
    expect(checkbox.checked).toEqual(false);
    expect(checkbox.indeterminate).toEqual(false);
  });
  it('should render selected state', function () {
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(uut.TriStateCheckbox, {
      value: 1
    }));
    var checkbox = wrapper.find('input[type="checkbox"]').getDOMNode();
    expect(checkbox.checked).toEqual(true);
    expect(checkbox.indeterminate).toEqual(false);
  });
  it('should render indeterminate state', function () {
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(uut.TriStateCheckbox, {
      value: -1
    }));
    var checkbox = wrapper.find('input[type="checkbox"]').getDOMNode();
    expect(checkbox.indeterminate).toEqual(true);
  });
  it('should trigger events on click', function () {
    var clicked = false;
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(uut.TriStateCheckbox, {
      value: 1,
      onClick: function onClick() {
        clicked = true;
      }
    }));
    var checkbox = wrapper.find('input[type="checkbox"]');
    checkbox.props().onClick();
    expect(clicked).toEqual(true);
  });
});