"use strict";

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

var _enzyme = require("enzyme");

var _styledComponents = require("../styled-components.js");

var _optionList = _interopRequireDefault(require("../option-list.js"));

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

var mockItem = {
  label: 'item1'
};

function getSharedProps() {
  return {
    item: mockItem,
    getItemLabel: function getItemLabel(item) {
      return item.label;
    }
  };
}

describe('Option List Stateless Component', function () {
  test('basic renders', function () {
    var component = (0, _enzyme.mount)(_react.default.createElement(_optionList.default, getSharedProps()));
    expect(component.find(_styledComponents.ListItem)).toExist();
    expect(component.find(_styledComponents.ListItem).first().text()).toEqual(mockItem.label);
  });
  test('renders with components overrides', function () {
    var NewListItem = function NewListItem() {
      return _react.default.createElement("div", {
        id: "list-item"
      });
    };

    var props = _objectSpread({}, getSharedProps(), {
      overrides: {
        ListItem: {
          component: NewListItem,
          props: {
            custom: 'prop'
          }
        }
      }
    });

    var component = (0, _enzyme.mount)(_react.default.createElement(_optionList.default, props));
    expect(component.find(_styledComponents.ListItem)).not.toExist();
    expect(component.find(NewListItem)).toExist();
    expect(component.find(NewListItem).prop('custom')).toEqual('prop');
  });
});