()
| 26 | } |
| 27 | |
| 28 | function createMockApp(): MockApp { |
| 29 | const files = new Map<string, TFile>(); |
| 30 | const metadata = new Map<string, { frontmatter: Record<string, unknown> }>(); |
| 31 | |
| 32 | const app = { |
| 33 | __files: files, |
| 34 | __metadata: metadata, |
| 35 | __metadataReads: 0, |
| 36 | vault: { |
| 37 | getMarkdownFiles: jest.fn(() => Array.from(files.values())), |
| 38 | getAbstractFileByPath: jest.fn((path: string) => files.get(path) ?? null), |
| 39 | on: jest.fn(() => ({})), |
| 40 | }, |
| 41 | metadataCache: { |
| 42 | getFileCache: jest.fn((file: TFile) => { |
| 43 | app.__metadataReads++; |
| 44 | return metadata.get(file.path) ?? null; |
| 45 | }), |
| 46 | on: jest.fn(() => ({})), |
| 47 | offref: jest.fn(), |
| 48 | }, |
| 49 | } as unknown as MockApp; |
| 50 | |
| 51 | return app; |
| 52 | } |
| 53 | |
| 54 | function createFile(app: MockApp, path: string, frontmatter: Record<string, unknown>): void { |
| 55 | const file = new TFile(path); |
no test coverage detected