import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__ from "@tachybase/test/client";
import * as __WEBPACK_EXTERNAL_MODULE_vitest__ from "vitest";
import * as __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__ from "../utils/index.mjs";
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.describe)('utils', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE_vitest__.describe)('normalizeContainer', ()=>{
        let originalConsoleWarn;
        beforeEach(()=>{
            originalConsoleWarn = console.warn;
        });
        afterEach(()=>{
            console.warn = originalConsoleWarn;
        });
        it('when container is undefined or null, return null', ()=>{
            const fn = vitest.fn();
            console.warn = fn;
            expect((0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.normalizeContainer)(void 0)).toBeNull();
            expect(fn).toBeCalledTimes(1);
        });
        it('when container is string and can not find element, return null', ()=>{
            const fn = vitest.fn();
            console.warn = fn;
            expect((0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.normalizeContainer)('#app')).toBeNull();
            expect(fn).toBeCalledTimes(1);
        });
        it('when container is string and can find element, return element', ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                id: "app",
                children: "App"
            }));
            expect((0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.normalizeContainer)('#app')).toBeInTheDocument();
        });
        it('when container is element, return element', ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                id: "app",
                children: "App"
            }));
            const element = document.getElementById('#app');
            expect((0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.normalizeContainer)(element)).toBe(element);
        });
    });
    (0, __WEBPACK_EXTERNAL_MODULE_vitest__.describe)('compose', ()=>{
        const Hello = (param)=>{
            let { children } = param;
            return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
                children: [
                    "Hello ",
                    children
                ]
            });
        };
        const World = (param)=>{
            let { name, children } = param;
            return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
                children: [
                    /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                        children: "World"
                    }),
                    /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                        children: name
                    }),
                    /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                        children: children
                    })
                ]
            });
        };
        const Foo = ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                children: "Foo"
            });
        it('compose without LastComponent', ()=>{
            const composeFn = (0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.compose)([
                Hello,
                void 0
            ], [
                World,
                {
                    name: 'aaa'
                }
            ]);
            const Compose = composeFn();
            (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Compose, {}));
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Hello')).toBeInTheDocument();
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('aaa')).toBeInTheDocument();
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('World')).toBeInTheDocument();
        });
        it('compose with LastComponent', ()=>{
            const composeFn = (0, __WEBPACK_EXTERNAL_MODULE__utils_index_mjs__.compose)([
                Hello,
                void 0
            ]);
            const Compose = composeFn(Foo);
            (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Compose, {}));
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Hello')).toBeInTheDocument();
            expect(__WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.screen.getByText('Foo')).toBeInTheDocument();
        });
    });
});
