()
| 19 | }; |
| 20 | |
| 21 | function 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 | |
| 47 | function createFile(app: MockApp, path: string, frontmatter: Record<string, unknown>): void { |
| 48 | const file = new TFile(path); |
no test coverage detected