Index `before`, write `after` over it, sync (scoped to `paths` when given); return the graph and a full index of the final tree.
(before: Files, after: Files, paths?: string[])
| 82 | |
| 83 | /** Index `before`, write `after` over it, sync (scoped to `paths` when given); return the graph and a full index of the final tree. */ |
| 84 | async function syncEdit(before: Files, after: Files, paths?: string[]): Promise<{ root: string; graph: CodeGraph; full: string[] }> { |
| 85 | const root = tempRoot(); |
| 86 | write(root, before); |
| 87 | const graph = await index(root); |
| 88 | expect(fooCalledBy(graph)).toEqual(['src/a.ts::foo']); |
| 89 | write(root, after); |
| 90 | await graph.sync(paths ? { paths } : {}); |
| 91 | const fullRoot = tempRoot(); |
| 92 | write(fullRoot, { ...before, ...after }); |
| 93 | return { root, graph, full: stateOf(fullRoot, await index(fullRoot)) }; |
| 94 | } |
| 95 | |
| 96 | const BEFORE: Files = { |
| 97 | 'package.json': JSON.stringify({ name: 'app' }), |
no test coverage detected