MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / mockProjectsFetch

Function mockProjectsFetch

graph-ui/src/components/StatsTab.test.tsx:8–42  ·  view source on GitHub ↗
(extra?: (url: string, init?: RequestInit) => Response | undefined)

Source from the content-addressed store, hash-verified

6import { messages } from "../lib/i18n";
7
8function mockProjectsFetch(extra?: (url: string, init?: RequestInit) => Response | undefined) {
9 const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
10 const url = String(input);
11 const overridden = extra?.(url, init);
12 if (overridden) return overridden;
13 if (url === "/rpc") {
14 return new Response(JSON.stringify({
15 result: { content: [{ text: JSON.stringify({ projects: [] }) }] },
16 }), { status: 200, headers: { "Content-Type": "application/json" } });
17 }
18 if (url.startsWith("/api/ui-config")) {
19 return new Response(JSON.stringify({ lang: "en" }), {
20 status: 200,
21 headers: { "Content-Type": "application/json" },
22 });
23 }
24 if (url.startsWith("/api/browse")) {
25 return new Response(JSON.stringify({
26 path: "/home/dev",
27 parent: "/home",
28 dirs: ["alpha", "beta"],
29 roots: ["/", "D:/"],
30 }), { status: 200, headers: { "Content-Type": "application/json" } });
31 }
32 if (url === "/api/index") {
33 return new Response(JSON.stringify({ status: "indexing", slot: 0 }), {
34 status: 202,
35 headers: { "Content-Type": "application/json" },
36 });
37 }
38 return new Response("{}", { status: 200 });
39 });
40 vi.stubGlobal("fetch", fetchMock);
41 return fetchMock;
42}
43
44describe("StatsTab index modal", () => {
45 afterEach(() => {

Callers 1

StatsTab.test.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected