'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _enzyme = require('enzyme');

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

var _VirtualizedList2 = _interopRequireDefault(_VirtualizedList);

var _ListTable = require('./ListTable.component');

var _ListTable2 = _interopRequireDefault(_ListTable);

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 table', function () {
		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(
			_ListTable2.default,
			{
				collection: _collection2.default,
				height: 600,
				id: 'my-list',
				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).not.toBe('RowSelection(undefined)');
	});

	it('should render table with sort props', function () {
		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(
			_ListTable2.default,
			{
				collection: _collection2.default,
				height: 600,
				id: 'my-list',
				sort: jest.fn(),
				sortBy: 'name',
				sortDirection: 'DESC',
				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();
	});

	it('should enhance the default rowRenderer with selection Higher Order renderer', function () {
		// when
		var wrapper = (0, _enzyme.shallow)(_react2.default.createElement(
			_ListTable2.default,
			{
				collection: _collection2.default,
				height: 600,
				id: 'my-list',
				isSelected: jest.fn(),
				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(undefined)');
	});
});