MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / createMockApp

Function createMockApp

tests/unit/services/filterCacheIndexing.test.ts:21–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19};
20
21function createMockApp(): MockApp {
22 const files = new Map<string, TFile>();
23 const metadata = new Map<string, { frontmatter: Record<string, unknown> }>();
24
25 const app = {
26 __files: files,
27 __metadata: metadata,
28 __metadataReads: 0,
29 vault: {
30 getMarkdownFiles: jest.fn(() => Array.from(files.values())),
31 getAbstractFileByPath: jest.fn((path: string) => files.get(path) ?? null),
32 on: jest.fn(() => ({})),
33 },
34 metadataCache: {
35 getFileCache: jest.fn((file: TFile) => {
36 app.__metadataReads++;
37 return metadata.get(file.path) ?? null;
38 }),
39 on: jest.fn(() => ({})),
40 offref: jest.fn(),
41 },
42 } as unknown as MockApp;
43
44 return app;
45}
46
47function createFile(app: MockApp, path: string, frontmatter: Record<string, unknown>): void {
48 const file = new TFile(path);

Callers 1

Calls 1

getMethod · 0.65

Tested by

no test coverage detected