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.each([['Root'], ['Label'], ['RadioMark'], ['Input']])('should send props to %s', function (subcomponent) {
    var _require = require('./index'),
        StyledRoot = _require.StyledRoot,
        StyledLabel = _require.StyledLabel,
        StyledRadioMark = _require.StyledRadioMark,
        StyledInput = _require.StyledInput,
        RadioGroup = _require.RadioGroup,
        StyledRadio = _require.StyledRadio;

    var mockComp = jest.fn(function () {
      return React.createElement("div", null, subcomponent);
    });
    overrides = {
      Root: StyledRoot,
      RadioMark: StyledRadioMark,
      Label: StyledLabel,
      Input: StyledInput
    };
    overrides[subcomponent] = mockComp;
    allProps.overrides = overrides;
    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 sharedProps = {
      $isError: allProps.isError,
      $checked: allProps.checked,
      $disabled: allProps.disabled
    };
    var actualProps = mockComp.mock.calls[0][0];
    var expectedProps = {
      Root: sharedProps,
      Label: _objectSpread({}, sharedProps, {
        $labelPlacement: allProps.labelPlacement
      }),
      RadioMark: sharedProps,
      Input: _objectSpread({
        type: 'radio',
        disabled: false
      }, sharedProps)
    };
    expect(actualProps).toMatchObject(expectedProps[subcomponent]);
  });
});