Open History to see the last commit
1import { Children, isValidElement, type ReactElement, type ReactNode } from "react";
2import { RouterProvider } from "@tanstack/react-router";
3import { describe, expect, it } from "vite-plus/test";
4
5import { ElectronBrowserHost } from "./browser/ElectronBrowserHost";
6import { PreviewAutomationHosts } from "./components/preview/PreviewAutomationHosts";
7import { AppAtomRegistryProvider } from "./rpc/atomRegistry";
8import type { AppRouter } from "./router";
9import { AppRoot } from "./AppRoot";
10
11describe("AppRoot", () => {
12 it("shares the application atom registry with routed UI and renderer-wide desktop hosts", () => {
13 const root = AppRoot({ router: {} as AppRouter });
14
15 expect(root.type).toBe(AppAtomRegistryProvider);
16 const children = Children.toArray(
17 (root as ReactElement<{ readonly children: ReactNode }>).props.children,
18 );
19 expect(children).toHaveLength(3);
20 expect(isValidElement(children[0]) && children[0].type).toBe(RouterProvider);
21 expect(isValidElement(children[1]) && children[1].type).toBe(PreviewAutomationHosts);
22 expect(isValidElement(children[2]) && children[2].type).toBe(ElectronBrowserHost);
23 });
24});