import React from 'react';
import { render, screen } from '@testing-library/react';
import { Popper } from './Popper';
describe('Popper tests', function () {
    afterEach(function () {
        jest.restoreAllMocks();
    });
    it('should render correct default state', function () {
        render(React.createElement(Popper, { open: true, anchorEl: document.body },
            React.createElement("div", { "data-reltio-id": "popperContent" })));
        expect(document.querySelectorAll('.backdrop')).toHaveLength(4);
        expect(screen.getByRole('tooltip')).toBeInTheDocument();
        expect(screen.getByTestId('popperContent')).toBeInTheDocument();
    });
    it('should not render backdrop and popper content if "open" is false', function () {
        render(React.createElement(Popper, { open: false, modal: true, anchorEl: document.body },
            React.createElement("div", { "data-reltio-id": "popperContent" })));
        expect(document.querySelectorAll('.backdrop')).toHaveLength(0);
        expect(screen.queryByTestId('popperContent')).not.toBeInTheDocument();
    });
    describe('Modal mode behavior', function () {
        it('should render 4 backdrop portal divs around anchorEl if "modal" and "open" props are true', function () {
            render(React.createElement(Popper, { open: true, modal: true, anchorEl: document.body },
                React.createElement("div", { "data-reltio-id": "popperContent" })));
            expect(document.querySelectorAll('.backdrop')).toHaveLength(4);
            expect(screen.getByTestId('popperContent')).toBeInTheDocument();
        });
        it('should render 1 backdrop portal div if "excludeAnchorFromBackdrop" is false', function () {
            render(React.createElement(Popper, { open: true, modal: true, excludeAnchorFromBackdrop: false, anchorEl: document.body },
                React.createElement("div", { "data-reltio-id": "popperContent" })));
            expect(document.querySelectorAll('.backdrop')).toHaveLength(1);
            expect(screen.getByTestId('popperContent')).toBeInTheDocument();
        });
        it('should not render backdrop portal divs around anchorEl if "modal" is false', function () {
            render(React.createElement(Popper, { open: true, modal: false, anchorEl: document.body },
                React.createElement("div", { "data-reltio-id": "popperContent" })));
            expect(document.querySelectorAll('.backdrop')).toHaveLength(0);
            expect(screen.getByTestId('popperContent')).toBeInTheDocument();
        });
    });
});
