@@ -186,6 +186,50 @@ describe("CodeParser", () => {
186186 const result = await parser [ "_performFallbackChunking" ] ( "test.js" , shortContent , "hash" , new Set ( ) )
187187 expect ( result ) . toEqual ( [ ] )
188188 } )
189+
190+ it ( "should respect 50-character minimum threshold for all languages" , async ( ) => {
191+ // Test content that is exactly 49 characters (should be filtered)
192+ const shortContent = "function f() { return 1; } // Exactly 49 chars!!!"
193+ expect ( shortContent . length ) . toBe ( 49 )
194+
195+ // Test content that is exactly 50 characters (should be included)
196+ const minContent = "function g() { return 42; } // Exactly 50 chars!!!"
197+ expect ( minContent . length ) . toBe ( 50 )
198+
199+ // Test content that is longer than 50 characters (should be included)
200+ const longContent = "function calculate() { return 1 + 2 + 3; } // This is longer than 50 characters"
201+ expect ( longContent . length ) . toBeGreaterThan ( 50 )
202+
203+ // Mock the language parser to return captures for our test content
204+ const mockCapture = ( content : string , startLine : number = 0 ) => ( {
205+ node : {
206+ text : content ,
207+ startPosition : { row : startLine } ,
208+ endPosition : { row : startLine } ,
209+ type : "function_declaration" ,
210+ childForFieldName : vi . fn ( ) . mockReturnValue ( null ) ,
211+ children : [ ] ,
212+ } ,
213+ name : "definition.function" ,
214+ } )
215+
216+ // Test short content (49 chars) - should be filtered out
217+ mockLanguageParser . js . query . captures . mockReturnValue ( [ mockCapture ( shortContent ) ] )
218+ const shortResult = await parser [ "parseContent" ] ( "test.js" , shortContent , "hash1" )
219+ expect ( shortResult ) . toEqual ( [ ] )
220+
221+ // Test minimum content (50 chars) - should be included
222+ mockLanguageParser . js . query . captures . mockReturnValue ( [ mockCapture ( minContent ) ] )
223+ const minResult = await parser [ "parseContent" ] ( "test.js" , minContent , "hash2" )
224+ expect ( minResult . length ) . toBe ( 1 )
225+ expect ( minResult [ 0 ] . content ) . toBe ( minContent )
226+
227+ // Test longer content - should be included
228+ mockLanguageParser . js . query . captures . mockReturnValue ( [ mockCapture ( longContent ) ] )
229+ const longResult = await parser [ "parseContent" ] ( "test.js" , longContent , "hash3" )
230+ expect ( longResult . length ) . toBe ( 1 )
231+ expect ( longResult [ 0 ] . content ) . toBe ( longContent )
232+ } )
189233 } )
190234
191235 describe ( "_chunkLeafNodeByLines" , ( ) => {
0 commit comments