'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _reactTestRenderer2 = _interopRequireDefault(_reactTestRenderer);

var _SelectAll = require('./SelectAll.component');

var _SelectAll2 = _interopRequireDefault(_SelectAll);

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

jest.mock('react-dom');

var props = {
	items: [{ id: 1 }, { id: 2 }],
	isSelected: jest.fn(),
	onToggleAll: jest.fn()
};

describe('SelectAll', function () {
	it('should render', function () {
		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_SelectAll2.default, props)).toJSON();

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

	it('should render id if provided', function () {
		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_SelectAll2.default, _extends({ id: 'list-toolbar' }, props))).toJSON();

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

	it('should be unchecked when there is no items', function () {
		// given
		var myProps = {
			items: [],
			isSelected: jest.fn(),
			onToggleAll: jest.fn()
		};

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

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