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