"use strict";

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

var _enzyme = require("enzyme");

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

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('Stateless radiogroup', function () {
  var wrapper,
      events = {};
  var allProps = {},
      overrides,
      isError,
      mockFn;
  beforeEach(function () {
    mockFn = jest.fn();
    isError = false;
    events = {
      onChange: mockFn,
      onMouseEnter: mockFn,
      onMouseLeave: mockFn,
      onFocus: mockFn,
      onBlur: mockFn
    };
    allProps = _objectSpread({}, events, {
      labelPlacement: 'left',
      isError: isError,
      autoFocus: false,
      disabled: false,
      checked: false
    });
  });
  afterEach(function () {
    jest.restoreAllMocks();
    wrapper && wrapper.unmount();
  });
  test('should check only radio button, which equals to selected value', function () {
    jest.mock('./radio', function () {
      return jest.fn(function () {
        return _react.default.createElement("div", null, "test");
      });
    });

    var _require = require('./index'),
        StyledRoot = _require.StyledRoot,
        StyledLabel = _require.StyledLabel,
        StyledRadioMark = _require.StyledRadioMark,
        StyledInput = _require.StyledInput,
        RadioGroup = _require.RadioGroup,
        StyledRadio = _require.StyledRadio;

    allProps.value = '2';
    allProps.overrides = overrides;
    overrides = {
      Root: StyledRoot,
      RadioMark: StyledRadioMark,
      Label: StyledLabel,
      Input: StyledInput
    };
    wrapper = (0, _enzyme.mount)(_react.default.createElement(RadioGroup, allProps, _react.default.createElement(StyledRadio, {
      value: "1"
    }, "First"), _react.default.createElement(StyledRadio, {
      value: "2"
    }, "Second"), _react.default.createElement(StyledRadio, {
      value: "3"
    }, "Third")));

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

    expect(radio.mock.calls[0][0].checked).toBeFalsy();
    expect(radio.mock.calls[1][0].checked).toBeTruthy();
    expect(radio.mock.calls[2][0].checked).toBeFalsy();
  });
});