"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("@testing-library/react");
const BFUIProvider_1 = require("../BFUIProvider");
const react_2 = require("@chakra-ui/react");
describe('BFUIProvider', () => {
    test('renders children correctly', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(BFUIProvider_1.BFUIProvider, { children: (0, jsx_runtime_1.jsx)("div", { "data-testid": "test-child", children: "Test Child" }) }));
        const childElement = react_1.screen.getByTestId('test-child');
        expect(childElement).toBeInTheDocument();
        expect(childElement).toHaveTextContent('Test Child');
    });
    test('applies default Chakra theme when no custom theme is provided', () => {
        // Mock the ChakraProvider to verify the theme prop
        jest.mock('@chakra-ui/react', () => {
            const original = jest.requireActual('@chakra-ui/react');
            return {
                ...original,
                ChakraProvider: jest.fn(({ children }) => (0, jsx_runtime_1.jsx)("div", { children: children })),
            };
        });
        const { ChakraProvider } = require('@chakra-ui/react');
        (0, react_1.render)((0, jsx_runtime_1.jsx)(BFUIProvider_1.BFUIProvider, { children: (0, jsx_runtime_1.jsx)("div", { children: "Test" }) }));
        // Verify that ChakraProvider was called with the default theme
        expect(ChakraProvider).toHaveBeenCalledWith(expect.objectContaining({
            theme: react_2.theme,
        }), expect.anything());
    });
    test('applies custom theme when provided', () => {
        // Mock the ChakraProvider to verify the theme prop
        jest.mock('@chakra-ui/react', () => {
            const original = jest.requireActual('@chakra-ui/react');
            return {
                ...original,
                ChakraProvider: jest.fn(({ children }) => (0, jsx_runtime_1.jsx)("div", { children: children })),
            };
        });
        const { ChakraProvider } = require('@chakra-ui/react');
        const customTheme = { colors: { brand: { 500: '#ff0000' } } };
        (0, react_1.render)((0, jsx_runtime_1.jsx)(BFUIProvider_1.BFUIProvider, { customTheme: customTheme, children: (0, jsx_runtime_1.jsx)("div", { children: "Test" }) }));
        // Verify that ChakraProvider was called with the custom theme
        expect(ChakraProvider).toHaveBeenCalledWith(expect.objectContaining({
            theme: customTheme,
        }), expect.anything());
    });
    test('passes additional props to ChakraProvider', () => {
        // Mock the ChakraProvider to verify props
        jest.mock('@chakra-ui/react', () => {
            const original = jest.requireActual('@chakra-ui/react');
            return {
                ...original,
                ChakraProvider: jest.fn(({ children }) => (0, jsx_runtime_1.jsx)("div", { children: children })),
            };
        });
        const { ChakraProvider } = require('@chakra-ui/react');
        (0, react_1.render)((0, jsx_runtime_1.jsx)(BFUIProvider_1.BFUIProvider, { resetCSS: false, portalZIndex: 1000, children: (0, jsx_runtime_1.jsx)("div", { children: "Test" }) }));
        // Verify that ChakraProvider was called with the additional props
        expect(ChakraProvider).toHaveBeenCalledWith(expect.objectContaining({
            resetCSS: false,
            portalZIndex: 1000,
        }), expect.anything());
    });
    test('handles nested components correctly', () => {
        const TestComponent = () => (0, jsx_runtime_1.jsx)("span", { "data-testid": "nested-component", children: "Nested Component" });
        (0, react_1.render)((0, jsx_runtime_1.jsx)(BFUIProvider_1.BFUIProvider, { children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(TestComponent, {}) }) }));
        const nestedComponent = react_1.screen.getByTestId('nested-component');
        expect(nestedComponent).toBeInTheDocument();
        expect(nestedComponent).toHaveTextContent('Nested Component');
    });
    test('renders with accessibility attributes', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(BFUIProvider_1.BFUIProvider, { children: (0, jsx_runtime_1.jsx)("div", { role: "main", "aria-label": "Main content", children: "Accessible content" }) }));
        const mainElement = react_1.screen.getByRole('main');
        expect(mainElement).toBeInTheDocument();
        expect(mainElement).toHaveAttribute('aria-label', 'Main content');
    });
});
//# sourceMappingURL=BFUIProvider.test.js.map