"use strict";

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

var _enzyme = require("enzyme");

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

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

describe('Stateful checkbox', function () {
  var allProps, wrapper;
  beforeEach(function () {
    allProps = {};
    jest.mock('../checkbox', function () {
      return jest.fn(function () {
        return _react.default.createElement("div", null, "test");
      });
    });
  });
  afterEach(function () {
    jest.restoreAllMocks();
    wrapper && wrapper.unmount();
  });
  test('should provide default styled components to render', function () {
    var _require = require('../index'),
        StyledRoot = _require.StyledRoot,
        StyledLabel = _require.StyledLabel,
        StyledCheckmark = _require.StyledCheckmark,
        StyledInput = _require.StyledInput,
        StatefulCheckbox = _require.StatefulCheckbox;

    allProps.overrides = {
      Root: StyledRoot,
      Label: StyledLabel,
      Checkmark: StyledCheckmark,
      Input: StyledInput
    };

    var checkbox = require('../checkbox');

    wrapper = (0, _enzyme.mount)(_react.default.createElement(StatefulCheckbox, allProps));
    var overrides = checkbox.mock.calls[0][0].overrides;
    expect(overrides).toEqual({
      Root: StyledRoot,
      Checkmark: StyledCheckmark,
      Label: StyledLabel,
      Input: StyledInput
    });
  });
  test('should pass all the other props to stateless checkbox', function () {
    var otherProps = {
      someProp: 'some other props',
      autoFocus: false
    };
    allProps = _objectSpread({}, allProps, otherProps);

    var _require2 = require('../index'),
        StatefulCheckbox = _require2.StatefulCheckbox;

    var checkbox = require('../checkbox');

    wrapper = (0, _enzyme.mount)(_react.default.createElement(StatefulCheckbox, allProps)); // eslint-disable-next-line no-unused-vars

    var _checkbox$mock$calls$ = checkbox.mock.calls[1][0],
        overrides = _checkbox$mock$calls$.overrides,
        rest = _objectWithoutProperties(_checkbox$mock$calls$, ["overrides"]);

    expect(rest).toMatchObject({
      someProp: 'some other props',
      checked: false,
      autoFocus: false,
      isIndeterminate: false
    });
  });
});