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 { HistoryDiffContext } from '../../../contexts/HistoryAppearanceContext';
import { EntityContext } from '../../../contexts/EntityContext';
import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
import { Tag } from './Tag';
var entity = { uri: 'uri1' };
var uiPath = 'https://uiPath';
var defaultProps = { value: 'Tag1' };
var setUp = function (_a) {
    var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.CustomProviders, CustomProviders = _d === void 0 ? React.Fragment : _d;
    var Providers = function (_a) {
        var children = _a.children;
        return (React.createElement(CustomProviders, null,
            React.createElement(MdmModuleProvider, { values: { entity: entity, uiPath: uiPath } }, children)));
    };
    return render(React.createElement(Tag, __assign({}, props)), { wrapper: Providers });
};
describe('Tag tests', function () {
    it('should render internal link', function () {
        setUp();
        var link = screen.getByText('Tag1');
        expect(link).not.toHaveClass('deleteAttribute');
        expect(link).toHaveAttribute('href', 'https://uiPath#p~com.reltio.plugins.tags.TagPerspective_e~uri1_tag~Tag1');
    });
    it('should render internal link for DTSS', function () {
        var entity = { uri: 'uri2', dataTenant: 'dtssTenant' };
        var Providers = function (_a) {
            var children = _a.children;
            return React.createElement(EntityContext.Provider, { value: entity }, children);
        };
        setUp({ CustomProviders: Providers });
        var link = screen.getByText('Tag1');
        expect(link).not.toHaveClass('deleteAttribute');
        expect(link).toHaveAttribute('href', 'https://uiPath#p~com.reltio.plugins.tags.TagPerspective_e~DTSS%2FdtssTenant%2Furi2_tag~Tag1');
    });
    it('should provide history className', function () {
        var _a;
        var value = defaultProps.value;
        var historyDiff = {
            appearance: {
                tags: (_a = {
                        otherValue: 'INSERT_ATTRIBUTE'
                    },
                    _a[value] = 'DELETE_ATTRIBUTE',
                    _a)
            },
            attributes: {},
            roles: [],
            tags: []
        };
        var Providers = function (_a) {
            var children = _a.children;
            return React.createElement(HistoryDiffContext.Provider, { value: historyDiff }, children);
        };
        setUp({ CustomProviders: Providers });
        expect(screen.getByText('Tag1')).toHaveClass('deleteAttribute');
    });
});
