"use strict";
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 jsdom_testing_mocks_1 = require("jsdom-testing-mocks");
var react_2 = require("@testing-library/react");
var ReadOnlyAttributeValuesBlock_1 = __importDefault(require("./ReadOnlyAttributeValuesBlock"));
describe('Read only attribute values block tests', function () {
    var resizeObserver = (0, jsdom_testing_mocks_1.mockResizeObserver)();
    it('should render read only attribute correctly', function () {
        var values = [
            {
                uri: 'entities/1/attributes/CountryCode/1',
                type: 'configuration/entityTypes/HCP/attributes/CountryCode',
                value: 'Italy',
                lookupCode: 'IT',
                ov: true
            }
        ];
        var attributeType = {
            uri: 'configuration/entityTypes/HCP',
            label: 'HCP',
            name: 'HCP',
            type: 'String',
            attributes: [
                {
                    label: 'Country Code',
                    name: 'CountryCode',
                    type: 'String',
                    uri: 'configuration/entityTypes/HCP/attributes/CountryCode'
                }
            ]
        };
        (0, react_2.render)(react_1.default.createElement(ReadOnlyAttributeValuesBlock_1.default, { attributeType: attributeType, values: values }));
        react_2.screen.getByText('Italy (IT)');
    });
    it('should render read only image attributes line', function () {
        var attributeType = {
            name: 'ImageGallery',
            type: 'Image',
            uri: 'configuration/entityTypes/Series/attributes/ImageGallery',
            attributes: [
                {
                    name: 'Url',
                    type: 'String',
                    uri: 'configuration/entityTypes/Series/attributes/ImageGallery/attributes/Url'
                },
                {
                    name: 'UrlThumbnail',
                    type: 'String',
                    uri: 'configuration/entityTypes/Series/attributes/ImageGallery/attributes/UrlThumbnail'
                }
            ]
        };
        var values = [
            {
                value: {
                    Url: [
                        {
                            type: 'configuration/entityTypes/Series/attributes/ImageGallery/attributes/Url',
                            ov: true,
                            value: '/test.jpg',
                            uri: 'entities/1Rd2I9Mt/attributes/ImageGallery/39V5GWJZv/Url/39V5GWWMh'
                        }
                    ],
                    UrlThumbnail: [
                        {
                            type: 'configuration/entityTypes/Series/attributes/ImageGallery/attributes/UrlThumbnail',
                            ov: true,
                            value: '/test.jpg',
                            uri: 'entities/1Rd2I9Mt/attributes/ImageGallery/39V5GWJZv/UrlThumbnail/39V5GWWMh'
                        }
                    ]
                },
                ov: true,
                uri: 'entities/1Rd2I9Mt/attributes/ImageGallery/39V5GWJZv'
            }
        ];
        var container = (0, react_2.render)(react_1.default.createElement(ReadOnlyAttributeValuesBlock_1.default, { attributeType: attributeType, values: values })).container;
        resizeObserver.mockElementSize(container.children[0], { contentBoxSize: { inlineSize: 600 } });
        (0, react_2.act)(function () {
            resizeObserver.resize();
        });
        expect(react_2.screen.getByRole('img')).toHaveAttribute('src', '/test.jpg');
    });
    it('should render nested read only attribute correctly', function () {
        var attributeType = {
            type: 'Nested',
            uri: 'configuration/entityTypes/HCP/attributes/NestedTest',
            name: 'NestedTest',
            label: 'Nested Test',
            attributes: [
                {
                    uri: 'configuration/entityTypes/HCP/attributes/NestedTest/attributes/FirstName',
                    name: 'FirstName',
                    label: 'First Name',
                    type: 'String'
                },
                {
                    uri: 'configuration/entityTypes/HCP/attributes/NestedTest/attributes/LastName',
                    name: 'LastName',
                    label: 'Last Name',
                    type: 'String'
                }
            ]
        };
        var values = [
            {
                label: 'Nested test label 1',
                value: {
                    FirstName: [
                        {
                            value: 'Viktor',
                            uri: 'entities/eNt1/attributes/NestedTest/gd42423/FirstName/8fBsP38A'
                        }
                    ]
                },
                uri: 'entities/eNt1/attributes/NestedTest/gd42423'
            },
            {
                label: 'Nested test label 2',
                value: {
                    LastName: [
                        {
                            value: 'Ivanov',
                            uri: 'entities/eNt1/attributes/NestedTest/ksApL29/LastName/o7BnD6mJ'
                        }
                    ]
                },
                uri: 'entities/eNt1/attributes/NestedTest/ksApL29'
            }
        ];
        (0, react_2.render)(react_1.default.createElement(ReadOnlyAttributeValuesBlock_1.default, { expanded: true, attributeType: attributeType, values: values }));
        react_2.screen.getByText('Nested test label 1');
        react_2.screen.getByText('First Name');
        react_2.screen.getByText('Viktor');
        react_2.screen.getByText('Nested test label 2');
        react_2.screen.getByText('Last Name');
        react_2.screen.getByText('Ivanov');
    });
});
