"use strict";

var _jsxRuntime = require("react/jsx-runtime");

var _enzyme = require("enzyme");

var _RadioItem = _interopRequireDefault(require("../RadioItem"));

var _RadioItemModule = _interopRequireDefault(require("../RadioItem.module.css"));

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

describe('RadioItem', function () {
  test('should support adding text as children', function () {
    var radioItem = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioItem["default"], {
      children: "Hello RadioItem"
    }));
    var expected = 'Hello RadioItem';
    var actual = radioItem.find('ItemContent').text();
    expect(actual).toBe(expected);
  });
  test('should render correct icon when not selected', function () {
    var radioItem = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioItem["default"], {
      children: "Hello RadioItem"
    }));
    var expected = 0;
    var actual = radioItem.find(".".concat(_RadioItemModule["default"].selected)).length;
    expect(actual).toBe(expected);
  });
  test('should render correct icon when selected', function () {
    var radioItem = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioItem["default"], {
      selected: true,
      children: "Hello RadioItem"
    }));
    var expected = 1;
    var actual = radioItem.find(".".concat(_RadioItemModule["default"].selected)).first().length;
    expect(actual).toBe(expected);
  });
  test('should support custom icon', function () {
    var radioItem = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioItem["default"], {
      icon: "check",
      children: "Hello RadioItem"
    }));
    var expected = 'check';
    var actual = radioItem.find('Icon').prop('children');
    expect(actual).toBe(expected);
  });
  test('should toggle selected prop when clicked', function () {
    var handleToggle = jest.fn();
    var radioItem = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioItem["default"], {
      onToggle: handleToggle,
      children: "Hello RadioItem"
    }));
    radioItem.find('RadioItemBase').simulate('click');
    var expected = true;
    var actual = handleToggle.mock.calls[0][0].selected;
    expect(actual).toBe(expected);
  });
  test('should toggle selected prop to false when initiated as selected', function () {
    var handleToggle = jest.fn();
    var radioItem = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioItem["default"], {
      onToggle: handleToggle,
      selected: true,
      children: "Hello RadioItem"
    }));
    radioItem.find('RadioItemBase').simulate('click');
    var expected = false;
    var actual = handleToggle.mock.calls[0][0].selected;
    expect(actual).toBe(expected);
  });
  test('should not toggle selected prop when initiated as disabled', function () {
    var handleToggle = jest.fn();
    var radioItem = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioItem["default"], {
      disabled: true,
      onToggle: handleToggle,
      children: "Hello RadioItem"
    }));
    radioItem.find('RadioItemBase').simulate('click');
    var expected = 0;
    var actual = handleToggle.mock.calls.length;
    expect(actual).toBe(expected);
  });
});