'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _enzyme = require('enzyme');

var _ActionSplitDropdown = require('./ActionSplitDropdown.component');

var _ActionSplitDropdown2 = _interopRequireDefault(_ActionSplitDropdown);

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

var items = [{
	label: 'From Local',
	onClick: jest.fn()
}, {
	label: 'From Remote',
	onClick: jest.fn()
}];

describe('ActionSplitDropdown', function () {
	it('should render a button with label', function () {
		// given
		var props = {
			label: 'Add File',
			onClick: jest.fn(),
			items: items
		};

		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_ActionSplitDropdown2.default, props));

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

	it('should render a button with icon and label', function () {
		// given
		var props = {
			label: 'Add File',
			icon: 'fa fa-plus',
			onClick: jest.fn(),
			items: items
		};

		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_ActionSplitDropdown2.default, props));

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

	it('should render items with icons', function () {
		// given
		var props = {
			label: 'Add File',
			icon: 'fa fa-plus',
			onClick: jest.fn(),
			items: [{
				label: 'From Local',
				onClick: jest.fn(),
				icon: 'fa fa-plus'
			}, {
				label: 'From Remote',
				onClick: jest.fn(),
				icon: 'fa fa-plus'
			}]
		};

		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_ActionSplitDropdown2.default, props));

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

	it('should render "no option" item when items array is empty', function () {
		// given
		var props = {
			label: 'Add File',
			icon: 'fa fa-plus',
			onClick: jest.fn(),
			items: [],
			emptyDropdownLabel: 'No option'
		};

		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_ActionSplitDropdown2.default, props));

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