import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { describe, it, expect } from "vitest";
import { renderToString } from "react-dom/server";
import { MountContext } from "../browser/react/mount-context.js";
import { useMount } from "../browser/react/use-mount.js";
function MountDisplay() {
    const mount = useMount();
    return _jsx("span", { "data-mount": mount, children: mount });
}
describe("useMount()", () => {
    it('returns "/" when no provider', () => {
        const html = renderToString(_jsx(MountDisplay, {}));
        expect(html).toContain("/");
        expect(html).toContain('data-mount="/"');
    });
    it("returns correct mount path from provider", () => {
        const html = renderToString(_jsx(MountContext.Provider, { value: "/articles", children: _jsx(MountDisplay, {}) }));
        expect(html).toContain("/articles");
        expect(html).toContain('data-mount="/articles"');
    });
    it("nested providers: inner overrides outer", () => {
        const html = renderToString(_jsx(MountContext.Provider, { value: "/articles", children: _jsx(MountContext.Provider, { value: "/articles/comments", children: _jsx(MountDisplay, {}) }) }));
        expect(html).toContain("/articles/comments");
        expect(html).toContain('data-mount="/articles/comments"');
    });
    it("sibling providers are independent", () => {
        function App() {
            return (_jsxs("div", { children: [_jsx(MountContext.Provider, { value: "/blog", children: _jsx(MountDisplay, {}) }), _jsx(MountContext.Provider, { value: "/shop", children: _jsx(MountDisplay, {}) })] }));
        }
        const html = renderToString(_jsx(App, {}));
        expect(html).toContain('data-mount="/blog"');
        expect(html).toContain('data-mount="/shop"');
    });
});
//# sourceMappingURL=use-mount.test.js.map