import { DataTypes } from '@reltio/mdm-sdk';
import { groupColumnsDataByMatchAttributes } from './helpers';
describe('tableHelpers tests', function () {
    describe('groupColumnsDataByMatchAttributes', function () {
        it('should not modify match attributes if they are empty', function () {
            var columnsData = [];
            expect(groupColumnsDataByMatchAttributes([], columnsData)).toBe(columnsData);
        });
        it('should group columnsData correctly', function () {
            var matchAttributes = [
                'configuration/entityTypes/HCP/attributes/Address/attributes/Zip/attributes/Code',
                'configuration/entityTypes/HCP/attributes/Name',
                'configuration/entityTypes/HCP/attributes/Location/attributes/City'
            ];
            var columnsData = [
                {
                    id: 'profile',
                    label: 'Entity Id',
                    dataTypeDefinition: { type: DataTypes.TYPE_STRING }
                },
                {
                    id: 'attributes.Address',
                    label: 'Address',
                    dataTypeDefinition: {
                        type: DataTypes.TYPE_NESTED
                    }
                },
                {
                    id: 'attributes.Address.City',
                    label: 'City',
                    dataTypeDefinition: { type: DataTypes.TYPE_STRING }
                },
                {
                    id: 'attributes.Address.Zip',
                    label: 'Zip',
                    dataTypeDefinition: {
                        type: DataTypes.TYPE_NESTED
                    }
                },
                {
                    id: 'attributes.Address.Zip.Code',
                    label: 'Code',
                    dataTypeDefinition: { type: DataTypes.TYPE_STRING }
                },
                {
                    id: 'attributes.Date',
                    label: 'Date',
                    dataTypeDefinition: { type: DataTypes.TYPE_STRING }
                },
                {
                    id: 'attributes.Name',
                    label: 'Name',
                    dataTypeDefinition: { type: DataTypes.TYPE_STRING }
                },
                {
                    id: 'attributes.Location',
                    label: 'Location',
                    dataTypeDefinition: {
                        type: DataTypes.TYPE_REFERENCE
                    }
                }
            ];
            expect(groupColumnsDataByMatchAttributes(matchAttributes, columnsData)).toEqual([
                {
                    id: 'match',
                    label: 'Match attributes',
                    columns: [
                        {
                            id: 'attributes.Address',
                            label: 'Address',
                            dataTypeDefinition: {
                                type: DataTypes.TYPE_NESTED
                            }
                        },
                        {
                            id: 'attributes.Address.Zip',
                            label: 'Zip',
                            dataTypeDefinition: {
                                type: DataTypes.TYPE_NESTED
                            }
                        },
                        {
                            id: 'attributes.Address.Zip.Code',
                            label: 'Code',
                            dataTypeDefinition: { type: DataTypes.TYPE_STRING }
                        },
                        {
                            id: 'attributes.Name',
                            label: 'Name',
                            dataTypeDefinition: { type: DataTypes.TYPE_STRING }
                        },
                        {
                            id: 'attributes.Location',
                            label: 'Location',
                            dataTypeDefinition: {
                                type: DataTypes.TYPE_REFERENCE
                            }
                        }
                    ]
                },
                {
                    id: 'all',
                    label: 'All attributes',
                    columns: [
                        {
                            id: 'profile',
                            label: 'Entity Id',
                            dataTypeDefinition: { type: DataTypes.TYPE_STRING }
                        },
                        {
                            id: 'attributes.Address',
                            label: 'Address',
                            dataTypeDefinition: {
                                type: DataTypes.TYPE_NESTED
                            }
                        },
                        {
                            id: 'attributes.Address.City',
                            label: 'City',
                            dataTypeDefinition: { type: DataTypes.TYPE_STRING }
                        },
                        {
                            id: 'attributes.Date',
                            label: 'Date',
                            dataTypeDefinition: { type: DataTypes.TYPE_STRING }
                        }
                    ]
                }
            ]);
        });
    });
});
