"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 react_2 = require("@testing-library/react");
var Popper_1 = require("./Popper");
describe('Popper tests', function () {
    afterEach(function () {
        jest.restoreAllMocks();
    });
    it('should render correct default state', function () {
        (0, react_2.render)(react_1.default.createElement(Popper_1.Popper, { open: true, anchorEl: document.body },
            react_1.default.createElement("div", { "data-reltio-id": "popperContent" })));
        expect(document.querySelectorAll('.backdrop')).toHaveLength(4);
        expect(react_2.screen.getByRole('tooltip')).toBeInTheDocument();
        expect(react_2.screen.getByTestId('popperContent')).toBeInTheDocument();
    });
    it('should not render backdrop and popper content if "open" is false', function () {
        (0, react_2.render)(react_1.default.createElement(Popper_1.Popper, { open: false, modal: true, anchorEl: document.body },
            react_1.default.createElement("div", { "data-reltio-id": "popperContent" })));
        expect(document.querySelectorAll('.backdrop')).toHaveLength(0);
        expect(react_2.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 () {
            (0, react_2.render)(react_1.default.createElement(Popper_1.Popper, { open: true, modal: true, anchorEl: document.body },
                react_1.default.createElement("div", { "data-reltio-id": "popperContent" })));
            expect(document.querySelectorAll('.backdrop')).toHaveLength(4);
            expect(react_2.screen.getByTestId('popperContent')).toBeInTheDocument();
        });
        it('should render 1 backdrop portal div if "excludeAnchorFromBackdrop" is false', function () {
            (0, react_2.render)(react_1.default.createElement(Popper_1.Popper, { open: true, modal: true, excludeAnchorFromBackdrop: false, anchorEl: document.body },
                react_1.default.createElement("div", { "data-reltio-id": "popperContent" })));
            expect(document.querySelectorAll('.backdrop')).toHaveLength(1);
            expect(react_2.screen.getByTestId('popperContent')).toBeInTheDocument();
        });
        it('should not render backdrop portal divs around anchorEl if "modal" is false', function () {
            (0, react_2.render)(react_1.default.createElement(Popper_1.Popper, { open: true, modal: false, anchorEl: document.body },
                react_1.default.createElement("div", { "data-reltio-id": "popperContent" })));
            expect(document.querySelectorAll('.backdrop')).toHaveLength(0);
            expect(react_2.screen.getByTestId('popperContent')).toBeInTheDocument();
        });
    });
});
