import React from 'react';
import { renderHook } from '@testing-library/react-hooks';
import { ExpandedAttributesProvider, useAttributeExpanded } from './index';
var setUp = function (attributeUri, attributeUris) {
    var DefaultProviders = function (_a) {
        var children = _a.children;
        return (React.createElement(ExpandedAttributesProvider, { attributeUris: attributeUris }, children));
    };
    return renderHook(function (_a) {
        var attributeUri = _a.attributeUri;
        return useAttributeExpanded(attributeUri);
    }, {
        initialProps: { attributeUri: attributeUri },
        wrapper: attributeUris ? DefaultProviders : function (_a) {
            var children = _a.children;
            return React.createElement(React.Fragment, null, children);
        }
    });
};
describe('useAttributeExpanded tests', function () {
    it('should return false if no expanded context present', function () {
        var result = setUp('entities/1/attributes/Simple/1').result;
        expect(result.current).toBe(false);
    });
    it('should return false if no attributes in expanded context', function () {
        var result = setUp('entities/1/attributes/Nested/1', []).result;
        expect(result.current).toBe(false);
    });
    it('should return true if attribute in expanded context', function () {
        var result = setUp('entities/1/attributes/Nested/1', ['entities/1/attributes/Nested/1']).result;
        expect(result.current).toBe(true);
    });
    it('should return true if subnested attribute in expanded context', function () {
        var result = setUp('entities/1/attributes/Nested/1', ['entities/1/attributes/Nested/1/SubNested/1']).result;
        expect(result.current).toBe(true);
    });
});
