(files: Record<string, string>, fromName: string)
| 16 | let cg: CodeGraph | null = null; |
| 17 | |
| 18 | async function calls(files: Record<string, string>, fromName: string): Promise<string[]> { |
| 19 | tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-2599-')); |
| 20 | for (const [rel, source] of Object.entries(files)) { |
| 21 | fs.mkdirSync(path.dirname(path.join(tempDir, rel)), { recursive: true }); |
| 22 | fs.writeFileSync(path.join(tempDir, rel), source); |
| 23 | } |
| 24 | cg = await CodeGraph.init(tempDir, { index: true }); |
| 25 | cg.resolveReferences(); |
| 26 | const from = cg.getNodesByKind('function').find((n) => n.name === fromName)!; |
| 27 | expect(from).toBeDefined(); |
| 28 | return cg |
| 29 | .getOutgoingEdges(from.id) |
| 30 | .filter((e) => e.kind === 'calls') |
| 31 | .map((e) => cg!.getNode(e.target)) |
| 32 | .filter((n): n is NonNullable<typeof n> => !!n) |
| 33 | .map((n) => `${n.kind}:${n.qualifiedName}`) |
| 34 | .sort(); |
| 35 | } |
| 36 | |
| 37 | afterEach(() => { |
| 38 | cg?.close(); |
no test coverage detected