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__Application_mjs__ from "../Application.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__ from "../hooks/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__Plugin_mjs__ from "../Plugin.mjs";
function _define_property(obj, key, value) {
    if (key in obj) Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
    });
    else obj[key] = value;
    return obj;
}
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.describe)('Application Hooks', ()=>{
    (0, __WEBPACK_EXTERNAL_MODULE_vitest__.describe)('useApp()', ()=>{
        it('should return the application instance', async ()=>{
            const app = new __WEBPACK_EXTERNAL_MODULE__Application_mjs__.Application();
            const Hello = ()=>{
                const app1 = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useApp)();
                expect(app).toBe(app1);
                return null;
            };
            app.addProviders([
                Hello
            ]);
            const Root = app.getRootComponent();
            (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Root, {}));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)(10);
        });
    });
    (0, __WEBPACK_EXTERNAL_MODULE_vitest__.describe)('useRouter()', ()=>{
        it('should return the router instance', async ()=>{
            const app = new __WEBPACK_EXTERNAL_MODULE__Application_mjs__.Application();
            const Hello = ()=>{
                const router = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useRouter)();
                expect(app.router).toBe(router);
                return null;
            };
            app.addProviders([
                Hello
            ]);
            const Root = app.getRootComponent();
            (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Root, {}));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)(10);
        });
    });
    (0, __WEBPACK_EXTERNAL_MODULE_vitest__.describe)('usePlugin()', ()=>{
        it('should return the plugin instance', async ()=>{
            class DemoPlugin extends __WEBPACK_EXTERNAL_MODULE__Plugin_mjs__.Plugin {
                constructor(...args){
                    super(...args), _define_property(this, "test", 'test');
                }
            }
            const Hello = ()=>{
                const demo = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.usePlugin)('demo');
                const demo2 = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.usePlugin)(DemoPlugin);
                expect(demo).toBeInstanceOf(DemoPlugin);
                expect(demo2).toBeInstanceOf(DemoPlugin);
                expect(demo.test).toBe('test');
                expect(demo2.test).toBe('test');
                return null;
            };
            const app = new __WEBPACK_EXTERNAL_MODULE__Application_mjs__.Application({
                plugins: [
                    [
                        DemoPlugin,
                        {
                            name: 'demo'
                        }
                    ]
                ],
                providers: [
                    Hello
                ]
            });
            const Root = app.getRootComponent();
            (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.render)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Root, {}));
            await (0, __WEBPACK_EXTERNAL_MODULE__tachybase_test_client__.sleep)(10);
        });
    });
});
