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; }

/*
Copyright (c) 2018 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import { mount } from 'enzyme';
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.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 = mount(React.createElement(RadioGroup, allProps, React.createElement(StyledRadio, {
      value: "1"
    }, "First"), React.createElement(StyledRadio, {
      value: "2"
    }, "Second"), React.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();
  });
});