"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _enzyme = require("enzyme");

var _ = _interopRequireDefault(require("."));

describe('TutorialReferencePicker', function () {
  var node;
  var props;
  beforeEach(function () {
    props = {
      endpoints: [{
        categoryId: '1',
        title: 'Petstore',
        children: [{
          _id: '123',
          api: {
            apiSetting: '222',
            method: 'get'
          },
          title: 'Get Pets'
        }]
      }],
      referenceDisplay: ['123'],
      setReferenceSelection: jest.fn()
    };
    node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], props));
  });
  it('should display reference picker parent', function () {
    expect(node.find('.TutorialReferencePicker').length).toBeGreaterThan(0);
  });
  it('should display reference picker child', function () {
    var item = node.find('.Menu-Item_arrow').first();
    item.simulate('click');
    var header = node.find('.TutorialReferencePicker-Header');
    expect(header).toHaveLength(1);
  });
  it('should close submenu on parent click', function () {
    var item = node.find('.Menu-Item_arrow').first();
    item.simulate('click');
    var subItem = node.find('MenuItem').at(0);
    subItem.simulate('click');
    var header = node.find('.TutorialReferencePicker-Header');
    expect(header).toHaveLength(0);
  });
  it('should propogate selection to parent', function () {
    var item = node.find('.Menu-Item_arrow').first();
    item.simulate('click');
    var subItem = node.find('MenuItem').at(1);
    subItem.simulate('click');
    expect(props.setReferenceSelection).toHaveBeenCalledWith('123');
  });
});