diff --git a/__tests__/cli-node-command.test.ts b/__tests__/cli-node-command.test.ts index dfd28acf8..c11e0ad56 100644 --- a/__tests__/cli-node-command.test.ts +++ b/__tests__/cli-node-command.test.ts @@ -39,6 +39,7 @@ describe('codegraph node — argument handling (#1044)', () => { tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-node-cmd-')); fs.mkdirSync(path.join(tempDir, 'src')); fs.writeFileSync(path.join(tempDir, 'src/util.ts'), 'export function util(x: number){ return x + 1; }\n'); + fs.writeFileSync(path.join(tempDir, 'src/other.ts'), 'export function util(x: number){ return x - 1; }\n'); const cg = CodeGraph.initSync(tempDir); await cg.indexAll(); cg.close(); @@ -71,6 +72,14 @@ describe('codegraph node — argument handling (#1044)', () => { expect(stdout).toContain('Location:'); }); + it('a symbol pinned with -f includes the selected definition body (#1284)', () => { + const { stdout, code } = runNode(tempDir, ['util', '-f', 'src/util.ts']); + expect(code).toBe(0); + expect(stdout).toContain('src/util.ts'); + expect(stdout).toContain('return x + 1'); + expect(stdout).not.toContain('return x - 1'); + }); + it('neither symbol nor file gives a usage error, not commander\'s cryptic one', () => { const { stderr, code } = runNode(tempDir, []); expect(code).not.toBe(0);