'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _enzyme = require('enzyme');

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

var _Header = require('./Header.component');

var _Header2 = _interopRequireDefault(_Header);

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

describe('Header', function () {
	it('should trigger callback when clicking on header button', function () {
		// given
		var props = {
			headerDefault: [{
				label: 'Add item',
				icon: 'talend-plus',
				id: 'add',
				onClick: jest.fn() // provided click callback
			}]
		};
		var headerInstance = _react2.default.createElement(_Header2.default, props);

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

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

		// then
		expect(buttons.length).toBe(1);
		expect(props.headerDefault[0].onClick).toBeCalled();
	});
});