var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React from "react";
import { render, waitFor } from "@testing-library/react";
import { describe, it, expect, vi, beforeEach } from "vitest";
import { BottomSlider } from ".";
const onExpandContaractMock = vi.fn();
vi.mock("./Header", () => ({
    Header: ({ onClick }) => (React.createElement("button", { "data-testid": "header", onClick: onClick }, "Header")),
}));
vi.mock("../Slider", () => ({
    Slider: (_a) => {
        var { children, isOpen, className, direction } = _a, rest = __rest(_a, ["children", "isOpen", "className", "direction"]);
        return (React.createElement("div", Object.assign({ "data-testid": "slider", "data-is-open": isOpen, "data-direction": direction, className: className }, rest), children));
    },
}));
describe("BottomSlider", () => {
    beforeEach(() => {
        vi.resetAllMocks();
    });
    it("should render the BottomSlider component", () => {
        const { getByTestId } = render(React.createElement(BottomSlider, { isOpen: false, onExpandContract: onExpandContaractMock }));
        const sliderElement = getByTestId("slider");
        const headerElement = getByTestId("header");
        expect(sliderElement).toBeInTheDocument();
        expect(sliderElement).toHaveAttribute("data-is-open", "false");
        expect(headerElement).toBeInTheDocument();
    });
    it("should toggle expansion state when header is clicked", () => __awaiter(void 0, void 0, void 0, function* () {
        const { getByTestId } = render(React.createElement(BottomSlider, { isOpen: true, isExpanded: true, onExpandContract: onExpandContaractMock }));
        const headerElement = getByTestId("header");
        yield waitFor(() => {
            headerElement.click();
        });
        expect(onExpandContaractMock).toHaveBeenCalledTimes(1);
    }));
    it("should render children inside the BottomSlider", () => {
        const { getByTestId } = render(React.createElement(BottomSlider, { isOpen: true, onExpandContract: onExpandContaractMock },
            React.createElement("div", { "data-testid": "child-element" }, "Child Element")));
        const childElement = getByTestId("child-element");
        expect(childElement).toBeInTheDocument();
        expect(childElement).toHaveTextContent("Child Element");
    });
    it("should allow for full area clickable to expand/collapse", () => __awaiter(void 0, void 0, void 0, function* () {
        const { getByTestId } = render(React.createElement(BottomSlider, { isOpen: true, isExpanded: false, fullAreaClickable: true, onExpandContract: onExpandContaractMock }));
        const sliderElement = getByTestId("slider");
        yield waitFor(() => {
            sliderElement.click();
        });
        expect(onExpandContaractMock).toHaveBeenCalledTimes(1);
    }));
    it("should not call onExpandContract when fullAreaClickable is false and slider is clicked", () => __awaiter(void 0, void 0, void 0, function* () {
        const { getByTestId } = render(React.createElement(BottomSlider, { isOpen: true, isExpanded: false, fullAreaClickable: false, onExpandContract: onExpandContaractMock }));
        const sliderElement = getByTestId("slider");
        yield waitFor(() => {
            sliderElement.click();
        });
        expect(onExpandContaractMock).not.toHaveBeenCalled();
    }));
});
//# sourceMappingURL=index.test.js.map