'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _enzyme = require('enzyme');

var _ActionDropdown = require('./ActionDropdown.component');

var _ActionDropdown2 = _interopRequireDefault(_ActionDropdown);

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

describe('ActionDropdown', function () {
	it('should call onSelect callback when click on item', function () {
		// given
		var onSelectClick = jest.fn();
		var props = {
			id: 'dropdwon-id',
			label: 'Dropdown',
			onSelect: onSelectClick,
			items: [{ id: 'item1', label: 'Item 1' }, { id: 'item2', label: 'Item 2' }]
		};
		var actionDropdownInstance = (0, _enzyme.mount)(_react2.default.createElement(_ActionDropdown2.default, props));

		// when
		actionDropdownInstance.find('MenuItem').at(0).find('SafeAnchor').simulate('click');

		// then
		expect(onSelectClick).toBeCalledWith(jasmine.anything(), props.items[0]);

		// when
		actionDropdownInstance.find('MenuItem').at(1).find('SafeAnchor').simulate('click');

		// then
		expect(onSelectClick).toBeCalledWith(jasmine.anything(), props.items[1]);
	});
});