'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _enzyme = require('enzyme');

var _ListGrid = require('./ListGrid.component');

var _ListGrid2 = _interopRequireDefault(_ListGrid);

var _VirtualizedList = require('../VirtualizedList.component');

var _VirtualizedList2 = _interopRequireDefault(_VirtualizedList);

var _RowLarge = require('../RowLarge');

var _RowLarge2 = _interopRequireDefault(_RowLarge);

var _collection = require('../collection');

var _collection2 = _interopRequireDefault(_collection);

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

describe('ListGrid', function () {
	it('should render react-virtualized list', function () {
		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(
			_ListGrid2.default,
			{
				collection: _collection2.default,
				height: 600,
				id: 'my-list',
				rowHeight: 130,
				rowRenderer: _RowLarge2.default,
				width: 1024
			},
			_react2.default.createElement(_VirtualizedList2.default.Content, {
				label: 'Id',
				dataKey: 'id'
			}),
			_react2.default.createElement(_VirtualizedList2.default.Content, {
				label: 'Name',
				dataKey: 'name'
			}),
			_react2.default.createElement(_VirtualizedList2.default.Content, {
				label: '',
				dataKey: 'description'
			})
		));

		// then
		expect(wrapper.node).toMatchSnapshot();
		expect(wrapper.node.props.rowRenderer.displayName).toBe('VirtualizedList(RowLarge)');
	});

	it('should enhance the rowRenderer with selection Higher Order renderer', function () {
		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(
			_ListGrid2.default,
			{
				collection: _collection2.default,
				height: 600,
				id: 'my-list',
				isSelected: jest.fn(),
				rowHeight: 130,
				rowRenderer: _RowLarge2.default,
				selectionToggle: jest.fn(),
				width: 1024
			},
			_react2.default.createElement(_VirtualizedList2.default.Content, {
				label: 'Id',
				dataKey: 'id'
			}),
			_react2.default.createElement(_VirtualizedList2.default.Content, {
				label: 'Name',
				dataKey: 'name'
			})
		));

		// then
		expect(wrapper.node.props.rowRenderer.displayName).toBe('RowSelection(VirtualizedList(RowLarge))');
	});

	it('should render no-rows component', function () {
		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(_ListGrid.NoRow, null));

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