| 432 | })); |
| 433 | |
| 434 | const spyContext = (nodes: Node[]): { ctx: ResolutionContext; lookups: () => number } => { |
| 435 | let scanned = 0; |
| 436 | const ctx: ResolutionContext = { |
| 437 | getNodesInFile: () => [], |
| 438 | getNodesByName: (name) => { |
| 439 | const hit = nodes.filter((n) => n.name === name); |
| 440 | scanned += hit.length; |
| 441 | return hit; |
| 442 | }, |
| 443 | getNodesByQualifiedName: () => [], |
| 444 | getNodesByKind: () => [], |
| 445 | fileExists: () => true, |
| 446 | readFile: () => null, |
| 447 | getProjectRoot: () => '/test', |
| 448 | getAllFiles: () => [], |
| 449 | getNodesByLowerName: () => [], |
| 450 | getImportMappings: () => [], |
| 451 | }; |
| 452 | return { ctx, lookups: () => scanned }; |
| 453 | }; |
| 454 | |
| 455 | it('declines a method call (`obj.init`) above the ceiling instead of scoring K candidates', () => { |
| 456 | const { ctx } = spyContext(makeManyMethods(CEILING + 1, 'init')); |