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';
import { ListItemProfile, ProfileImg, ProfileTitle, ProfileSubtitle, ProfileBody } from '../styled-components.js';
import OptionProfile from '../option-profile.js';
var mockItem = {
  title: 'David Smith',
  subtitle: 'Senior Engineering Manager',
  body: 'Uber Everything',
  imgUrl: 'imgUrl'
};

function getSharedProps() {
  return {
    item: mockItem,
    getProfileItemLabels: function getProfileItemLabels(_ref) {
      var title = _ref.title,
          subtitle = _ref.subtitle,
          body = _ref.body;
      return {
        title: title,
        subtitle: subtitle,
        body: body
      };
    },
    getProfileItemImg: function getProfileItemImg(item) {
      return item.imgUrl;
    },
    getProfileItemImgText: function getProfileItemImgText(item) {
      return item.title;
    }
  };
}

describe('Option Profile Stateless Component', function () {
  test('basic renders', function () {
    var component = mount(React.createElement(OptionProfile, getSharedProps()));
    expect(component.find(ListItemProfile)).toExist();
    expect(component.find(ProfileTitle).first().text()).toEqual(mockItem.title);
    expect(component.find(ProfileSubtitle).first().text()).toEqual(mockItem.subtitle);
    expect(component.find(ProfileBody).first().text()).toEqual(mockItem.body);
    expect(component.find(ProfileImg).first().prop('src')).toEqual(mockItem.imgUrl);
  });
  test('renders with custom image component', function () {
    function MockComponent() {
      return React.createElement("div", null);
    }

    var props = _objectSpread({}, getSharedProps(), {
      getProfileItemImg: function getProfileItemImg(item) {
        return MockComponent;
      }
    });

    var component = mount(React.createElement(OptionProfile, props));
    expect(component.find(MockComponent)).toExist();
  });
  test('renders with components overrides', function () {
    function MockComponent() {
      return React.createElement("div", null);
    }

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

    var component = mount(React.createElement(OptionProfile, props));
    expect(component.find(ListItemProfile)).not.toExist();
    expect(component.find(MockComponent)).toExist();
    expect(component.find(MockComponent).prop('custom')).toEqual('prop');
  });
});