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 { screen, render } from '@testing-library/react';
import { MdmModuleProvider } from '../contexts/MdmModuleContext';
import { DataTenantBadge } from './DataTenantBadge';
var defaultDataTenants = [
    {
        id: 'uitest3',
        name: 'DT_TEST',
        label: 'DT:TEST'
    },
    {
        id: 'hmcyo4cu',
        name: 'withoutPrefix',
        label: 'withoutPrefix'
    },
    {
        id: 'uitest2',
        name: 'DT_TEST'
    }
];
var defaultMdmValues = {
    dataTenants: defaultDataTenants
};
var setUp = function (props, mdmValues) {
    if (mdmValues === void 0) { mdmValues = defaultMdmValues; }
    var Providers = function (_a) {
        var children = _a.children;
        return (React.createElement(MdmModuleProvider, { values: mdmValues }, children));
    };
    return render(React.createElement(DataTenantBadge, __assign({}, props)), { wrapper: Providers });
};
describe('DataTenantBage tests', function () {
    it('should pass className to root element correctly', function () {
        setUp({ dataTenantId: 'uitest3', className: 'dataTenantBadge' });
        expect(screen.getByLabelText('DT:TEST')).toHaveClass('dataTenantBadge');
    });
    it('should render correct label if dataTenantId exists in dataTenants', function () {
        setUp({ dataTenantId: 'uitest3' });
        screen.getByText('DT:T');
    });
    it('should render correct label if dataTenants is not exists', function () {
        var mdmValues = { dataTenants: [] };
        setUp({ dataTenantId: 'uitest3' }, mdmValues);
        screen.getByText('DT:');
    });
    it('should render correct label if dataTenantId does not exist in dataTenants', function () {
        setUp({ dataTenantId: 'notExistedTenantId' });
        screen.getByText('DT:');
    });
    it('should render correct label if data tenant name does not start with "DT:"', function () {
        setUp({ dataTenantId: 'hmcyo4cu' });
        screen.getByText('DT:W');
    });
    it('should render correct tooltip if dataTenantId has a label', function () {
        setUp({ dataTenantId: 'uitest3' });
        screen.getByLabelText('DT:TEST');
    });
    it('should not render tooltip if dataTenant does not have a label property', function () {
        setUp({ dataTenantId: 'uitest2' });
        expect(screen.queryByTestId('reltio-data-tenant-bage-tooltip')).not.toBeInTheDocument();
    });
    it('should not render tooltip if dataTenantId does not exist in dataTenants', function () {
        setUp({ dataTenantId: 'notExistedTenantId' });
        expect(screen.queryByTestId('reltio-data-tenant-bage-tooltip')).not.toBeInTheDocument();
    });
});
