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 { ProfileBand } from './ProfileBand';
var metadata = {
    entityTypes: [
        {
            uri: 'configuration/entityTypes/HCP',
            attributes: [
                {
                    type: 'String',
                    name: 'FirstName',
                    uri: 'configuration/entityTypes/HCP/attributes/FirstName'
                }
            ],
            businessCardAttributeURIs: ['configuration/entityTypes/HCP/attributes/FirstName'],
            typeImage: 'images/defaultImage/image.png'
        }
    ]
};
var defaultEntity = {
    attributes: {
        FirstName: [
            {
                ov: true,
                value: 'First name',
                uri: 'entities/1MheIGmc/attributes/FirstName/2l2ktkUn0',
                type: 'configuration/entityTypes/HCP/attributes/FirstName'
            }
        ]
    },
    label: 'Entity one',
    secondaryLabel: 'Entity expanded label',
    type: 'configuration/entityTypes/HCP',
    uri: 'entities/uioU78'
};
var defaultProps = { entity: defaultEntity, children: React.createElement("div", null, "Content") };
var defaultMdmValues = {
    showEntityId: true,
    absoluteImagePath: 'https://reltio.com/nui/imagePath',
    metadata: metadata
};
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(ProfileBand, __assign({}, props)), { wrapper: Providers });
};
describe('Profile band tests', function () {
    it('should render main parts correctly', function () {
        setUp();
        expect(screen.getByRole('img')).toHaveAttribute('src', 'https://reltio.com/nui/imagePath/images/defaultImage/image.png');
        screen.getByText('Entity one');
        screen.getByText('Entity expanded label');
        screen.getByText('First name');
        screen.getByText('Entity ID: uioU78');
        screen.getByText('Content');
    });
    it('should render inactive profile band correctly', function () {
        var entity = __assign(__assign({}, defaultEntity), { endDate: Date.now() - 10 });
        var props = __assign(__assign({}, defaultProps), { entity: entity });
        setUp({ props: props });
        expect(screen.getByTestId('reltio-profile-band').firstChild).toHaveClass('inactive');
    });
    it('should hide entity id for create mode', function () {
        var entity = __assign(__assign({}, defaultEntity), { uri: 'entities/uri$$1646115317921' });
        var props = __assign(__assign({}, defaultProps), { entity: entity });
        setUp({ props: props });
        expect(screen.queryByLabelText('Copy to clipboard')).not.toBeInTheDocument();
    });
    it('should hide entityId if "showEntityId" is false', function () {
        var mdmValues = __assign(__assign({}, defaultMdmValues), { showEntityId: false });
        setUp({ mdmValues: mdmValues });
        expect(screen.queryByLabelText('Copy to clipboard')).not.toBeInTheDocument();
    });
    it('should render custom label correctly using renderLabel prop', function () {
        var props = __assign(__assign({}, defaultProps), { renderLabel: function (label) { return "custom ".concat(label); } });
        setUp({ props: props });
        screen.getByText('custom Entity one');
    });
});
