Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AppRoot.test.tsx

22 lines987 Bytes

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 { AppAtomRegistryProvider } from "./rpc/atomRegistry";
7import type { AppRouter } from "./router";
8import { AppRoot } from "./AppRoot";
9​
10describe("AppRoot", () => {
11 it("shares the application atom registry with routed UI and the Electron browser host", () => {
12 const root = AppRoot({ router: {} as AppRouter });
13​
14 expect(root.type).toBe(AppAtomRegistryProvider);
15 const children = Children.toArray(
16 (root as ReactElement<{ readonly children: ReactNode }>).props.children,
17 );
18 expect(children).toHaveLength(2);
19 expect(isValidElement(children[0]) && children[0].type).toBe(RouterProvider);
20 expect(isValidElement(children[1]) && children[1].type).toBe(ElectronBrowserHost);
21 });
22});