import { getTableHeadData } from './helpers';
import { withFilter } from '../HOCs/withFilter';
jest.mock('../HOCs/withFilter', function () { return ({
    withFilter: jest.fn()
}); });
describe('helpers', function () {
    describe('getTableHeadData', function () {
        it('should convert columns data to head data correctly', function () {
            var headCellRenderer = function () { }, rowCellValueRenderer = function () { };
            var columnsData = [
                {
                    id: 'ID',
                    label: 'Label',
                    headCellRenderer: headCellRenderer,
                    rowCellValueRenderer: rowCellValueRenderer,
                    dataTypeDefinition: {
                        type: 'Type',
                        uri: 'types/uri'
                    },
                    sortable: true,
                    resizable: false,
                    draggable: true,
                    initialWidth: 200,
                    minWidth: 100
                }
            ];
            expect(getTableHeadData(columnsData)).toEqual([
                {
                    id: 'ID',
                    label: 'Label',
                    renderer: headCellRenderer,
                    sortable: true,
                    resizable: false,
                    draggable: true,
                    autoResize: true,
                    initialWidth: 200,
                    minWidth: 100
                }
            ]);
        });
        it('should create correct columns data for enabled filtering', function () {
            var headCellRenderer = function () { }, rowCellValueRenderer = function () { };
            var headCellRendererWithFilters = function () { };
            withFilter.mockReturnValue(function () { return headCellRendererWithFilters; });
            var dataTypeDefinition = {
                type: 'String'
            };
            var filterOptions = [{ value: 'filterOptionValue', label: 'filterOptionLabel' }];
            var columnsData = [
                {
                    id: 'ID',
                    label: 'Label',
                    headCellRenderer: headCellRenderer,
                    rowCellValueRenderer: rowCellValueRenderer,
                    sortable: true,
                    resizable: false,
                    initialWidth: 200,
                    minWidth: 100,
                    dataTypeDefinition: dataTypeDefinition,
                    filterOptions: filterOptions,
                    filterable: false
                }
            ];
            var filter = { value: '123', filter: 'equals' };
            var onFilter = jest.fn();
            expect(getTableHeadData(columnsData, { ID: filter }, onFilter)).toEqual([
                {
                    id: 'ID',
                    label: 'Label',
                    renderer: headCellRendererWithFilters,
                    sortable: true,
                    resizable: false,
                    autoResize: true,
                    initialWidth: 200,
                    minWidth: 100
                }
            ]);
            expect(withFilter).toHaveBeenCalledWith({
                filterable: false,
                dataTypeDefinition: dataTypeDefinition,
                filter: filter,
                filterOptions: filterOptions,
                onFilter: onFilter
            });
        });
    });
});
