var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import React from 'react';
import { render, screen } from '@testing-library/react';
import { MdmModuleProvider } from '../../../../../contexts/MdmModuleContext';
import { ActivityTypes } from '../../../types';
import { SynchronizationIssuesActivity } from './SynchronizationIssuesActivity';
var defaultItem = {
    id: '42uxv5X2',
    timestamp: 1652374313724,
    objectUri: 'entities/15T9kNFk',
    objectType: 'configuration/entityTypes/HCP',
    objectLabel: 'Andy Andy'
};
var defaultData = {
    uri: 'activities/0dcf97d0-5006-46d6-b82f-07579922e2f6',
    user: 'sfdc.connector.admin',
    label: 'label',
    timestamp: 1652374313724,
    items: [defaultItem],
    itemsTotal: 1
};
var defaultProps = {
    type: ActivityTypes.SFDC_CONNECTOR_SYNCHRONIZATION_ISSUE,
    data: defaultData
};
var defaultMdmValues = {
    uiPath: 'https://reltio.com/nui'
};
var setUp = function (_a) {
    var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d;
    var Providers = function (_a) {
        var children = _a.children;
        return (React.createElement(MdmModuleProvider, { values: mdmValues }, children));
    };
    return render(React.createElement(SynchronizationIssuesActivity, __assign({}, props)), { wrapper: Providers });
};
describe('Synchronization issues activity tests', function () {
    it('should render correctly', function () {
        setUp();
        screen.getByText('SFDC connector synchronization issue');
        expect(screen.getByText('Andy Andy')).toHaveAttribute('href', 'https://reltio.com/nui#p~com.reltio.plugins.entity.default.DefaultPerspective_e~entities/15T9kNFk');
        expect(screen.queryByTestId('synchronization-issues-activity-description')).not.toBeInTheDocument();
        expect(screen.queryByTestId('synchronization-issues-activity-items-total')).not.toBeInTheDocument();
    });
    it('should render relation uri correctly', function () {
        var props = __assign(__assign({}, defaultProps), { data: __assign(__assign({}, defaultData), { items: [
                    __assign(__assign({}, defaultItem), { objectUri: 'relations/15T9kNFk', objectType: 'configuration/relationTypes/HasAddress' })
                ] }) });
        setUp({ props: props });
        screen.getByText('relations/15T9kNFk');
    });
    it('should render description if it has been passed', function () {
        var props = __assign(__assign({}, defaultProps), { data: __assign(__assign({}, defaultData), { description: '{"label":"description"}' }) });
        setUp({ props: props });
        screen.getByText('description');
    });
    it('should render items total if itemsTotal is greater than 1', function () {
        var props = __assign(__assign({}, defaultProps), { data: __assign(__assign({}, defaultData), { itemsTotal: 2 }) });
        setUp({ props: props });
        screen.getByText('(2 records)');
    });
});
