The best way to control Claude Code, Codex and more from any computer or phone

main
tsx 51 lines 1.8 KB
Raw
1 import type { ReactNode } from "react";
2 import { act, Profiler } from "react";
3 import { createRoot } from "react-dom/client";
4 import { expect, it, vi } from "vite-plus/test";
5
6 const harness = vi.hoisted(() => ({
7 Passthrough: ({ children }: { children?: unknown }) => children,
8 }));
9
10 vi.mock("react-native", () => ({ View: harness.Passthrough }));
11 vi.mock("expo-image", () => ({ Image: () => <img alt="" /> }));
12 vi.mock("./ui/AppSymbol", () => ({ SymbolView: () => null }));
13 vi.mock("./ui/AppText", () => ({
14 AppText: ({ children }: { children?: ReactNode }) => <span>{children}</span>,
15 }));
16 vi.mock("../features/settings/appearance/AppearancePreferencesProvider", () => ({
17 useAppearancePreferences: () => ({ themeAppearance: "light" }),
18 }));
19 vi.mock("../state/assets", async () => {
20 const { Atom } = await import("effect/reactivity");
21 const url = Atom.make<string | null>("https://example.test/favicon.png");
22 return { projectFaviconUrlAtom: () => url };
23 });
24
25 import { EnvironmentId } from "@t3tools/contracts";
26
27 import { ProjectFavicon } from "./ProjectFavicon";
28
29 it("mounts the favicon image in the first commit", async () => {
30 (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
31 const container = document.createElement("div");
32 const root = createRoot(container);
33 const commits: string[] = [];
34 try {
35 await act(async () =>
36 root.render(
37 <Profiler id="favicon" onRender={(_id, phase) => commits.push(phase)}>
38 <ProjectFavicon
39 environmentId={EnvironmentId.make("env-1")}
40 projectTitle="Project"
41 workspaceRoot="/repo"
42 />
43 </Profiler>,
44 ),
45 );
46 expect(container.querySelector("img")).not.toBeNull();
47 expect(commits).toEqual(["mount"]);
48 } finally {
49 await act(async () => root.unmount());
50 }
51 });