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 { List } from '../styled-components.js';
import OptionList from '../option-list.js';
import Menu from '../menu.js';
var mockItems = [{
  label: 'item1'
}, {
  label: 'item2'
}];

function getSharedProps() {
  return {
    items: mockItems,
    getItemLabel: function getItemLabel(item) {
      return item.label;
    },
    rootRef: React.createRef()
  };
}

describe('Menu Stateless Component', function () {
  test('basic renders', function () {
    var component = mount(React.createElement(Menu, getSharedProps()));
    expect(component.find(List)).toExist();
    expect(component.find(List)).toHaveProp({
      $ref: React.createRef()
    });
    expect(component.find(OptionList)).toExist();
    component.setProps({
      getRequiredItemProps: function getRequiredItemProps(item, index) {
        return {
          key: String(index),
          isHighlighted: true
        };
      }
    });
    expect(component.find(OptionList).first()).toHaveProp({
      $isHighlighted: true
    });
  });
  test('renders with components overrides', function () {
    var NewOption = function NewOption() {
      return React.createElement("div", null);
    };

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

    var component = mount(React.createElement(Menu, props));
    expect(component.find(OptionList)).not.toExist();
    expect(component.find(NewOption)).toExist();
    expect(component.find(NewOption).first().prop('custom')).toEqual('prop');
  });
});