* Mock ResolutionContext for the React Native bridge resolver.
(nodes: Node[], fileContents: Record<string, string> = {})
| 11 | * Mock ResolutionContext for the React Native bridge resolver. |
| 12 | */ |
| 13 | function makeContext(nodes: Node[], fileContents: Record<string, string> = {}): ResolutionContext { |
| 14 | const byName = new Map<string, Node[]>(); |
| 15 | for (const n of nodes) { |
| 16 | const arr = byName.get(n.name); |
| 17 | if (arr) arr.push(n); |
| 18 | else byName.set(n.name, [n]); |
| 19 | } |
| 20 | // Files = union of node files + any extra fileContents keys (for files that |
| 21 | // have content like .mm bridge declarations but no extracted nodes yet). |
| 22 | const allFiles = new Set<string>( |
| 23 | [...nodes.map((n) => n.filePath), ...Object.keys(fileContents)] |
| 24 | ); |
| 25 | return { |
| 26 | getNodesInFile: (fp) => nodes.filter((n) => n.filePath === fp), |
| 27 | getNodesByName: (name) => byName.get(name) ?? [], |
| 28 | getNodesByQualifiedName: () => { throw new Error('not used'); }, |
| 29 | getNodesByKind: (kind) => nodes.filter((n) => n.kind === kind), |
| 30 | getNodesByLowerName: () => { throw new Error('not used'); }, |
| 31 | fileExists: (fp) => allFiles.has(fp), |
| 32 | readFile: (fp) => fileContents[fp] ?? null, |
| 33 | getProjectRoot: () => '/test', |
| 34 | getAllFiles: () => Array.from(allFiles), |
| 35 | getImportMappings: () => [], |
| 36 | }; |
| 37 | } |
| 38 | |
| 39 | function method( |
| 40 | name: string, |
no test coverage detected