"use strict";
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);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var react_2 = require("@testing-library/react");
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
var ProfileBand_1 = require("./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_1.default.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_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues }, children));
    };
    return (0, react_2.render)(react_1.default.createElement(ProfileBand_1.ProfileBand, __assign({}, props)), { wrapper: Providers });
};
describe('Profile band tests', function () {
    it('should render main parts correctly', function () {
        setUp();
        expect(react_2.screen.getByRole('img')).toHaveAttribute('src', 'https://reltio.com/nui/imagePath/images/defaultImage/image.png');
        react_2.screen.getByText('Entity one');
        react_2.screen.getByText('Entity expanded label');
        react_2.screen.getByText('First name');
        react_2.screen.getByText('Entity ID: uioU78');
        react_2.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(react_2.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(react_2.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(react_2.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 });
        react_2.screen.getByText('custom Entity one');
    });
});
