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 { HistoryDiffContext } from '../contexts/HistoryAppearanceContext';
import { Roles } from './Roles';
var mdmValues = {
    metadata: {
        roles: [
            { uri: 'role1', label: 'Role label 1' },
            { uri: 'role2', label: 'Role label 2' }
        ]
    }
};
var defaultProps = {
    values: ['role1', 'role2'],
    className: 'class1'
};
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: mdmValues }, children)));
    };
    return render(React.createElement(Roles, __assign({}, props)), { wrapper: Providers });
};
describe('Roles tests', function () {
    it('should render correctly', function () {
        setUp();
        var attributeValue = screen.getByTestId('reltio-attribute-value');
        expect(attributeValue).toHaveTextContent('Role label 1, Role label 2');
        expect(attributeValue).toHaveClass('class1');
    });
    it('should provide history className', function () {
        var historyDiff = {
            appearance: { roles: { otherValue: 'DELETE_ATTRIBUTE', role1: 'INSERT_ATTRIBUTE' } },
            attributes: {},
            roles: [],
            tags: []
        };
        var CustomProviders = function (_a) {
            var children = _a.children;
            return (React.createElement(HistoryDiffContext.Provider, { value: historyDiff }, children));
        };
        setUp({ CustomProviders: CustomProviders });
        expect(screen.getByText('Role label 1')).toHaveClass('insertAttribute');
    });
});
