(options?: { exists?: boolean; readFile?: string })
| 23 | }; |
| 24 | |
| 25 | function createFsFixture(options?: { exists?: boolean; readFile?: string }): MockFsFixture { |
| 26 | const writes: MockWrite[] = []; |
| 27 | const mkdirs: string[] = []; |
| 28 | const exists = options?.exists ?? false; |
| 29 | const readFileContent = options?.readFile; |
| 30 | |
| 31 | const fs = createMockFileSystemExecutor({ |
| 32 | existsSync: (targetPath) => (targetPath === configPath ? exists : false), |
| 33 | readFile: async (targetPath) => { |
| 34 | if (targetPath !== configPath) { |
| 35 | throw new Error(`Unexpected readFile path: ${targetPath}`); |
| 36 | } |
| 37 | if (readFileContent == null) { |
| 38 | throw new Error('readFile called but no readFile content was provided'); |
| 39 | } |
| 40 | return readFileContent; |
| 41 | }, |
| 42 | writeFile: async (targetPath, content) => { |
| 43 | writes.push({ path: targetPath, content }); |
| 44 | }, |
| 45 | mkdir: async (targetPath) => { |
| 46 | mkdirs.push(targetPath); |
| 47 | }, |
| 48 | }); |
| 49 | |
| 50 | return { fs, writes, mkdirs }; |
| 51 | } |
| 52 | |
| 53 | describe('project-config', () => { |
| 54 | describe('loadProjectConfig', () => { |
no test coverage detected