'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactTestRenderer = require('react-test-renderer');

var _reactTestRenderer2 = _interopRequireDefault(_reactTestRenderer);

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

var _ActionDropdown2 = _interopRequireDefault(_ActionDropdown);

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

jest.mock('react-dom');

var items = [{
	icon: 'talend-icon',
	label: 'document 1',
	onClick: jest.fn()
}, {
	label: 'document 2',
	onClick: jest.fn()
}];

describe('ActionDropdown', function () {
	it('should render a button with label', function () {
		// given
		var props = {
			id: 'dropdown-id',
			label: 'related items',
			items: items
		};

		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_ActionDropdown2.default, props)).toJSON();

		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should render a button with icon and label', function () {
		// given
		var props = {
			id: 'dropdown-id',
			label: 'related items',
			icon: 'fa fa-file-excel-o',
			items: items
		};

		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_ActionDropdown2.default, props)).toJSON();

		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should render a button with icon', function () {
		// given
		var props = {
			id: 'dropdown-id',
			label: 'related items',
			icon: 'fa fa-file-excel-o',
			items: items,
			tooltipPlacement: 'right',
			hideLabel: true
		};

		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_ActionDropdown2.default, props)).toJSON();

		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should render a button with "link" theme', function () {
		// given
		var props = {
			id: 'dropdown-id',
			label: 'related items',
			items: items,
			link: true
		};

		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_ActionDropdown2.default, props)).toJSON();

		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should render "no option" item when items array is empty', function () {
		// given
		var props = {
			id: 'dropdown-id',
			label: 'related items',
			items: []
		};

		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_ActionDropdown2.default, props)).toJSON();

		// then
		expect(wrapper).toMatchSnapshot();
	});
});