'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _enzyme = require('enzyme');

var _CellCheckbox = require('./CellCheckbox.component');

var _CellCheckbox2 = _interopRequireDefault(_CellCheckbox);

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

var columnData = {
	id: 'my-checkbox',
	label: 'My Test Check',
	onChange: jest.fn()
};

describe('CellActions', function () {
	it('should render checked checkbox', function () {
		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_CellCheckbox2.default, {
			cellData: true,
			columnData: columnData,
			rowIndex: 25
		}));

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

	it('should render unchecked checkbox', function () {
		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_CellCheckbox2.default, {
			cellData: false,
			columnData: columnData,
			rowIndex: 25
		}));

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

	it('should trigger callback on checkbox toggle', function () {
		// given
		var event = { target: 'lol' };
		var rowData = { id: 1 };

		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_CellCheckbox2.default, {
			cellData: true,
			columnData: columnData,
			rowData: rowData,
			rowIndex: 25
		}));
		wrapper.find('#my-checkbox-25-check').simulate('change', event);

		// then
		expect(columnData.onChange).toBeCalledWith(event, rowData);
	});
});