import { getFilterLabel } from './helpers';
import { DateRangeTypes } from '@reltio/mdm-sdk';
import { ActivityTypes } from '../types';
describe('getFilterLabel tests', function () {
    it('should return correct label for default filters', function () {
        var filters = {
            activities: [],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for one entityType', function () {
        var filters = {
            activities: [],
            entityTypes: [
                {
                    uri: 'configuration/entityTypes/HCP',
                    label: 'HCP',
                    attributes: []
                }
            ],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'HCP | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for two entityTypes', function () {
        var filters = {
            activities: [],
            entityTypes: [
                {
                    uri: 'configuration/entityTypes/HCP',
                    label: 'HCP',
                    attributes: []
                },
                {
                    uri: 'configuration/entityTypes/HCA',
                    label: 'HCA',
                    attributes: []
                }
            ],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'HCA + 1 type | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for more than two entityTypes', function () {
        var filters = {
            activities: [],
            entityTypes: [
                {
                    uri: 'configuration/entityTypes/HCP',
                    label: 'HCP',
                    attributes: []
                },
                {
                    uri: 'configuration/entityTypes/HCA',
                    label: 'HCA',
                    attributes: []
                },
                {
                    uri: 'configuration/entityTypes/HCB',
                    label: 'HCB',
                    attributes: []
                }
            ],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'HCA + 2 types | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for one activity', function () {
        var filters = {
            activities: [ActivityTypes.USER_LOGIN],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'Logged in | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for two activities', function () {
        var filters = {
            activities: [ActivityTypes.USER_LOGIN, ActivityTypes.ENTITY_CREATED],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'Logged in + 1 activity | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for more than two activities', function () {
        var filters = {
            activities: [ActivityTypes.USER_LOGIN, ActivityTypes.MODEL_UPDATED, ActivityTypes.RELATIONSHIP_REMOVED],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'Logged in + 2 activities | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for one user', function () {
        var filters = {
            activities: [],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: ['username1']
        };
        var expected = 'Within 4 months | username1';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for two users', function () {
        var filters = {
            activities: [],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: ['username2', 'username1']
        };
        var expected = 'Within 4 months | username2 + 1 user';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for more than two users', function () {
        var filters = {
            activities: [],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: ['username2', 'username1', 'username3']
        };
        var expected = 'Within 4 months | username2 + 2 users';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for one attribute', function () {
        var filters = {
            activities: [],
            attributes: [
                {
                    label: 'Activity',
                    value: 'configuration/entityTypes/HCP/attributes/activitywith',
                    attrType: {
                        label: 'Activity',
                        name: 'activitywith',
                        type: 'Reference',
                        uri: 'configuration/entityTypes/HCP/attributes/activitywith'
                    },
                    chipLabel: 'Activity',
                    level: 0
                }
            ],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'Activity | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for two attributes', function () {
        var filters = {
            activities: [],
            attributes: [
                {
                    label: 'Activity',
                    value: 'configuration/entityTypes/HCP/attributes/activitywith',
                    attrType: {
                        label: 'Activity',
                        name: 'activitywith',
                        type: 'Reference',
                        uri: 'configuration/entityTypes/HCP/attributes/activitywith'
                    },
                    chipLabel: 'Activity',
                    level: 0
                },
                {
                    label: 'Activity1',
                    value: 'configuration/entityTypes/HCP/attributes/activitywith1',
                    attrType: {
                        label: 'Activity',
                        name: 'activitywith1',
                        type: 'Reference',
                        uri: 'configuration/entityTypes/HCP/attributes/activitywith1'
                    },
                    chipLabel: 'Activity1',
                    level: 0
                }
            ],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'Activity + 1 attribute | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for more than two attributes', function () {
        var filters = {
            activities: [],
            attributes: [
                {
                    label: 'Activity',
                    value: 'configuration/entityTypes/HCP/attributes/activitywith',
                    attrType: {
                        label: 'Activity',
                        name: 'activitywith',
                        type: 'Reference',
                        uri: 'configuration/entityTypes/HCP/attributes/activitywith'
                    },
                    chipLabel: 'Activity',
                    level: 0
                },
                {
                    label: 'Activity1',
                    value: 'configuration/entityTypes/HCP/attributes/activitywith1',
                    attrType: {
                        label: 'Activity',
                        name: 'activitywith1',
                        type: 'Reference',
                        uri: 'configuration/entityTypes/HCP/attributes/activitywith1'
                    },
                    chipLabel: 'Activity1',
                    level: 0
                },
                {
                    label: 'Activity2',
                    value: 'configuration/entityTypes/HCP/attributes/activitywith2',
                    attrType: {
                        label: 'Activity2',
                        name: 'activitywith2',
                        type: 'Reference',
                        uri: 'configuration/entityTypes/HCP/attributes/activitywith2'
                    },
                    chipLabel: 'Activity2',
                    level: 0
                }
            ],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'Activity + 2 attributes | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for one source', function () {
        var filters = {
            activities: [],
            sources: [
                {
                    uri: 'configuration/sources/Reltio',
                    label: 'Reltio',
                    icon: 'images/source/reltio.png',
                    abbreviation: 'Reltio'
                }
            ],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'Reltio | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for two sources', function () {
        var filters = {
            activities: [],
            sources: [
                {
                    uri: 'configuration/sources/Reltio',
                    label: 'Reltio',
                    icon: 'images/source/reltio.png',
                    abbreviation: 'Reltio'
                },
                {
                    uri: 'configuration/sources/Test',
                    label: 'Test label',
                    icon: 'images/source/test.png',
                    abbreviation: 'TestAbbr'
                }
            ],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'Reltio + 1 source | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for more than two sources', function () {
        var filters = {
            activities: [],
            sources: [
                {
                    uri: 'configuration/sources/Reltio',
                    label: 'Reltio',
                    icon: 'images/source/reltio.png',
                    abbreviation: 'Reltio'
                },
                {
                    uri: 'configuration/sources/Test',
                    label: 'Test label',
                    icon: 'images/source/test.png',
                    abbreviation: 'TestAbbr'
                },
                {
                    uri: 'configuration/sources/TestSource',
                    label: 'Test label',
                    icon: 'images/source/test.png',
                    abbreviation: 'TestSource'
                }
            ],
            dateRange: {
                type: DateRangeTypes.WITHIN,
                period: [4, 'months']
            },
            users: []
        };
        var expected = 'Reltio + 2 sources | Within 4 months';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for ago period', function () {
        var filters = {
            activities: [],
            dateRange: {
                type: DateRangeTypes.AGO,
                period: [8, 'days']
            },
            users: []
        };
        var expected = 'More than 8 days ago';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for between period', function () {
        var filters = {
            activities: [],
            dateRange: {
                type: DateRangeTypes.BETWEEN,
                period: [new Date('06-01-2021'), new Date('06-16-2021')]
            },
            users: []
        };
        var expected = '06/01/2021 to 06/16/2021';
        expect(getFilterLabel(filters)).toBe(expected);
    });
    it('should return correct label for complex value', function () {
        var filters = {
            activities: [ActivityTypes.USER_LOGIN, ActivityTypes.COMMENT_ADDED, ActivityTypes.RELATIONSHIP_REMOVED],
            entityTypes: [
                {
                    uri: 'configuration/entityTypes/HCA',
                    label: 'HCA',
                    attributes: []
                },
                {
                    uri: 'configuration/entityTypes/HCB',
                    label: 'HCB',
                    attributes: []
                }
            ],
            attributes: [
                {
                    label: 'Activity',
                    value: 'configuration/entityTypes/HCP/attributes/activitywith',
                    attrType: {
                        label: 'Activity',
                        name: 'activitywith',
                        description: 'Activity',
                        type: 'Reference',
                        hidden: false,
                        important: false,
                        system: false,
                        searchable: true,
                        uri: 'configuration/entityTypes/HCP/attributes/activitywith'
                    },
                    chipLabel: 'Activity',
                    level: 0
                }
            ],
            sources: [
                {
                    uri: 'configuration/sources/Reltio',
                    label: 'Reltio',
                    icon: 'images/source/reltio.png',
                    abbreviation: 'Reltio'
                },
                {
                    uri: 'configuration/sources/Test',
                    label: 'Test label',
                    icon: 'images/source/test.png',
                    abbreviation: 'TestAbbr'
                }
            ],
            dateRange: {
                type: DateRangeTypes.BETWEEN,
                period: [new Date('06-01-2021'), new Date('06-16-2021')]
            },
            users: ['username2', 'username1', 'username3']
        };
        var expected = 'Logged in + 2 activities | HCA + 1 type | Activity | Reltio + 1 source | 06/01/2021 to 06/16/2021 | username2 + 2 users';
        expect(getFilterLabel(filters)).toBe(expected);
    });
});
