(cg: CodeGraph, active: boolean)
| 42 | } |
| 43 | |
| 44 | function assertBindings(cg: CodeGraph, active: boolean) { |
| 45 | const functions = cg.getNodesByKind('function'); |
| 46 | const run = functions.find(n => n.name === 'run' && n.filePath === 'consumer.ts')!; |
| 47 | const action = functions.find(n => n.name === 'reset' && n.filePath === 'store.ts')!; |
| 48 | const decoy = functions.find(n => n.name === 'reset' && n.filePath === 'decoy.ts')!; |
| 49 | const targets = cg.getOutgoingEdges(run.id).filter(e => e.kind === 'calls').map(e => e.target); |
| 50 | expect(targets.includes(action.id)).toBe(active); |
| 51 | expect(targets).not.toContain(decoy.id); |
| 52 | const pendingActions = cg.getUnresolvedReferencesFrom(run.id).filter(r => r.referenceName === 'reset'); |
| 53 | expect(pendingActions).toHaveLength(active ? 0 : 2); |
| 54 | |
| 55 | // Eligibility must not remove untyped qualified call-site evidence, including |
| 56 | // repeated/optional chains, or turn it into a guessed edge. |
| 57 | const effects = functions.find(n => n.name === 'effects' && n.filePath === 'consumer.ts')!; |
| 58 | expect(cg.getOutgoingEdges(effects.id).filter(e => e.kind === 'calls')).toEqual([]); |
| 59 | expect(cg.getUnresolvedReferencesFrom(effects.id).filter(r => r.referenceKind === 'calls') |
| 60 | .map(r => [r.referenceName, r.line, r.column])).toEqual([ |
| 61 | ['client.user.create', 8, 2], ['client.user.create', 9, 2], |
| 62 | ]); |
| 63 | } |
| 64 | |
| 65 | describe('store eligibility cache across edits and resolver contexts', () => { |
| 66 | it.each([false, true])('sync refreshes eligibility starting with getState=%s', async (initial) => { |
no test coverage detected