'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _enzyme = require('enzyme');

var _reactBootstrap = require('react-bootstrap');

var _Item = require('./Item.component');

var _Item2 = _interopRequireDefault(_Item);

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

var item = {
	values: ['toto'],
	itemProps: {
		key: 'values',
		onSubmitItem: jest.fn(), // provided click callback
		onAbortItem: jest.fn(), // provided click callback
		onSelectItem: jest.fn(), // provided click callback
		actions: [{
			label: 'Edit',
			id: 'edit',
			onClick: jest.fn() // provided click callback
		}, {
			label: 'Delete',
			id: 'delete',
			onClick: jest.fn() // provided click callback
		}]
	}
};

describe('Item', function () {
	it('should display value with three buttons and trigger callback on button title click', function () {
		// given
		var props = {
			item: item
		};
		var itemInstance = _react2.default.createElement(_Item2.default, props);

		// when
		var wrapper = (0, _enzyme.mount)(itemInstance);
		var buttons = wrapper.find(_reactBootstrap.Button);

		buttons.at(1).simulate('click', { stopPropagation: function stopPropagation() {} });

		// then
		expect(buttons.length).toBe(3);
		expect(props.item.itemProps.actions[0].onClick).toBeCalled();
	});

	it('should display value with three buttons and trigger callback on item click', function () {
		// given
		var props = {
			item: item
		};

		var itemInstance = _react2.default.createElement(_Item2.default, props);

		// when
		var wrapper = (0, _enzyme.mount)(itemInstance);
		var buttons = wrapper.find(_reactBootstrap.Button);

		buttons.at(0).simulate('click', { stopPropagation: function stopPropagation() {} });

		// then
		expect(buttons.length).toBe(3);
		expect(props.item.itemProps.onSelectItem).toBeCalled();
	});
});