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 { theme } from '../constants';
import { EntityTypeBadge } from './EntityTypeBadge';
var defaultMetadata = {
    entityTypes: [
        {
            uri: 'configuration/entityTypes/HCP',
            label: 'HCP'
        },
        {
            uri: 'configuration/entityTypes/HCO',
            label: 'HCO',
            typeColor: '#FFF'
        }
    ]
};
var defaultMdmValues = {
    metadata: defaultMetadata
};
var defaultEntity = { type: 'configuration/entityTypes/HCP', uri: 'entities/123' };
var defaultProps = {
    entity: defaultEntity
};
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(EntityTypeBadge, __assign({}, props)), { wrapper: Providers });
};
describe('EntityTypeBadge tests', function () {
    it('should render default (small) badge', function () {
        setUp();
        expect(screen.getByText('HCP')).toHaveClass('entityType-small');
    });
    it('should render medium badge', function () {
        var props = __assign(__assign({}, defaultProps), { size: 'medium' });
        setUp({ props: props });
        expect(screen.getByText('HCP')).toHaveClass('entityType-medium');
    });
    it('should use color from theme if entity type has not typeColor prop', function () {
        setUp();
        expect(screen.getByText('HCP')).toHaveStyle({ backgroundColor: theme.palette.primary.main, color: '#FFFFFF' });
    });
    it('should use color from typeColor prop from entityType if it exists', function () {
        var entity = { type: 'configuration/entityTypes/HCO', uri: 'entities/456' };
        var props = { entity: entity };
        setUp({ props: props });
        expect(screen.getByText('HCO')).toHaveStyle({ backgroundColor: '#FFF', color: '#212121' });
    });
});
