'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _enzyme = require('enzyme');

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

var _HeaderInput = require('./HeaderInput.component');

var _HeaderInput2 = _interopRequireDefault(_HeaderInput);

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

describe('Header input', function () {
	it('should trigger callback when clicking on header button', function () {
		// given
		var props = {
			headerInput: [{
				disabled: false,
				label: 'Validate',
				icon: 'talend-check',
				id: 'validate',
				onClick: jest.fn() // provided click callback
			}, {
				label: 'Abort',
				icon: 'talend-cross',
				id: 'abort',
				onClick: jest.fn() // provided click callback
			}]
		};
		var headerInputInstance = _react2.default.createElement(_HeaderInput2.default, props);

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

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

		// then
		expect(props.headerInput[0].onClick).toBeCalled();
		expect(props.headerInput[1].onClick).toBeCalled();
	});
});