@@ -8,7 +8,7 @@ import { createTables } from "../db";
88import type { CodemapDatabase } from "../db" ;
99import { hashContent } from "../hash" ;
1010import { openCodemapDatabase } from "../sqlite-db" ;
11- import { parseSnippetRest } from "./cmd-snippet" ;
11+ import { parseSnippetRest , renderSnippetTerminal } from "./cmd-snippet" ;
1212
1313describe ( "parseSnippetRest" , ( ) => {
1414 it ( "returns help on --help / -h" , ( ) => {
@@ -69,6 +69,43 @@ describe("parseSnippetRest", () => {
6969 } ) ;
7070} ) ;
7171
72+ describe ( "renderSnippetTerminal" , ( ) => {
73+ it ( "prints signature between location and source" , ( ) => {
74+ const lines : string [ ] = [ ] ;
75+ const origLog = console . log ;
76+ console . log = ( ...args : unknown [ ] ) => {
77+ lines . push (
78+ args . map ( ( a ) => ( typeof a === "string" ? a : String ( a ) ) ) . join ( " " ) ,
79+ ) ;
80+ } ;
81+ try {
82+ renderSnippetTerminal ( {
83+ matches : [
84+ {
85+ name : "foo" ,
86+ kind : "function" ,
87+ file_path : "src/a.ts" ,
88+ line_start : 1 ,
89+ line_end : 2 ,
90+ signature : "function foo(): void" ,
91+ is_exported : 1 ,
92+ parent_name : null ,
93+ visibility : null ,
94+ source : "line1\nline2" ,
95+ stale : false ,
96+ missing : false ,
97+ } ,
98+ ] ,
99+ } ) ;
100+ } finally {
101+ console . log = origLog ;
102+ }
103+ expect ( lines [ 0 ] ) . toBe ( "src/a.ts:1-2" ) ;
104+ expect ( lines [ 1 ] ) . toBe ( " function foo(): void" ) ;
105+ expect ( lines [ 2 ] ) . toBe ( "line1\nline2" ) ;
106+ } ) ;
107+ } ) ;
108+
72109describe ( "buildSnippetResult — source enrichment + envelope" , ( ) => {
73110 let projectRoot : string ;
74111 let db : CodemapDatabase ;
0 commit comments