"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var helpers_1 = require("./helpers");
describe('tableHelpers tests', function () {
    describe('groupColumnsDataByMatchAttributes', function () {
        it('should not modify match attributes if they are empty', function () {
            var columnsData = [];
            expect((0, helpers_1.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: mdm_sdk_1.DataTypes.TYPE_STRING }
                },
                {
                    id: 'attributes.Address',
                    label: 'Address',
                    dataTypeDefinition: {
                        type: mdm_sdk_1.DataTypes.TYPE_NESTED
                    }
                },
                {
                    id: 'attributes.Address.City',
                    label: 'City',
                    dataTypeDefinition: { type: mdm_sdk_1.DataTypes.TYPE_STRING }
                },
                {
                    id: 'attributes.Address.Zip',
                    label: 'Zip',
                    dataTypeDefinition: {
                        type: mdm_sdk_1.DataTypes.TYPE_NESTED
                    }
                },
                {
                    id: 'attributes.Address.Zip.Code',
                    label: 'Code',
                    dataTypeDefinition: { type: mdm_sdk_1.DataTypes.TYPE_STRING }
                },
                {
                    id: 'attributes.Date',
                    label: 'Date',
                    dataTypeDefinition: { type: mdm_sdk_1.DataTypes.TYPE_STRING }
                },
                {
                    id: 'attributes.Name',
                    label: 'Name',
                    dataTypeDefinition: { type: mdm_sdk_1.DataTypes.TYPE_STRING }
                },
                {
                    id: 'attributes.Location',
                    label: 'Location',
                    dataTypeDefinition: {
                        type: mdm_sdk_1.DataTypes.TYPE_REFERENCE
                    }
                }
            ];
            expect((0, helpers_1.groupColumnsDataByMatchAttributes)(matchAttributes, columnsData)).toEqual([
                {
                    id: 'match',
                    label: 'Match attributes',
                    columns: [
                        {
                            id: 'attributes.Address',
                            label: 'Address',
                            dataTypeDefinition: {
                                type: mdm_sdk_1.DataTypes.TYPE_NESTED
                            }
                        },
                        {
                            id: 'attributes.Address.Zip',
                            label: 'Zip',
                            dataTypeDefinition: {
                                type: mdm_sdk_1.DataTypes.TYPE_NESTED
                            }
                        },
                        {
                            id: 'attributes.Address.Zip.Code',
                            label: 'Code',
                            dataTypeDefinition: { type: mdm_sdk_1.DataTypes.TYPE_STRING }
                        },
                        {
                            id: 'attributes.Name',
                            label: 'Name',
                            dataTypeDefinition: { type: mdm_sdk_1.DataTypes.TYPE_STRING }
                        },
                        {
                            id: 'attributes.Location',
                            label: 'Location',
                            dataTypeDefinition: {
                                type: mdm_sdk_1.DataTypes.TYPE_REFERENCE
                            }
                        }
                    ]
                },
                {
                    id: 'all',
                    label: 'All attributes',
                    columns: [
                        {
                            id: 'profile',
                            label: 'Entity Id',
                            dataTypeDefinition: { type: mdm_sdk_1.DataTypes.TYPE_STRING }
                        },
                        {
                            id: 'attributes.Address',
                            label: 'Address',
                            dataTypeDefinition: {
                                type: mdm_sdk_1.DataTypes.TYPE_NESTED
                            }
                        },
                        {
                            id: 'attributes.Address.City',
                            label: 'City',
                            dataTypeDefinition: { type: mdm_sdk_1.DataTypes.TYPE_STRING }
                        },
                        {
                            id: 'attributes.Date',
                            label: 'Date',
                            dataTypeDefinition: { type: mdm_sdk_1.DataTypes.TYPE_STRING }
                        }
                    ]
                }
            ]);
        });
    });
});
