MCPcopy Create free account
hub / github.com/chhoumann/quickadd / createMockApp

Function createMockApp

tests/packages/packageExportService.test.ts:20–53  ·  view source on GitHub ↗
(options?: {
	existingPaths?: Record<string, string>;
})

Source from the content-addressed store, hash-verified

18import { encodeToBase64 } from "../../src/utils/base64";
19
20function createMockApp(options?: {
21 existingPaths?: Record<string, string>;
22}): App {
23 const existing = new Map<string, string>(
24 Object.entries(options?.existingPaths ?? {}),
25 );
26
27 const adapterExists = vi.fn(async (path: string) => existing.has(path));
28 const adapterRead = vi.fn(async (path: string) => {
29 const content = existing.get(path);
30 if (content === undefined) {
31 throw new Error(`Missing: ${path}`);
32 }
33 return content;
34 });
35 const adapterWrite = vi.fn(async (_path: string, _content: string) => {
36 /* noop for test */
37 });
38
39 const createFolder = vi.fn(async (folder: string) => {
40 existing.set(folder, "");
41 });
42
43 return {
44 vault: {
45 adapter: {
46 exists: adapterExists,
47 read: adapterRead,
48 write: adapterWrite,
49 },
50 createFolder,
51 },
52 } as unknown as App;
53}
54
55describe("packageExportService", () => {
56 const QUICKADD_VERSION = "2.5.0";

Callers 1

Calls 3

fnMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected