@@ -38,19 +38,30 @@ describe('crossFileContextUtil', function () {
38
38
tempFolder = ( await createTestWorkspaceFolder ( ) ) . uri . fsPath
39
39
} )
40
40
41
- describe ( 'should fetch 3 chunks and each chunk should contains 10 lines' , function ( ) {
41
+ describe ( 'should fetch 10 chunks and each chunk should contains 50 lines' , function ( ) {
42
42
async function assertCorrectCodeChunk ( ) {
43
- await openATextEditorWithText ( sampleFileOf60Lines , 'CrossFile.java' , tempFolder , { preview : false } )
43
+ await openATextEditorWithText ( sampleFileOf60Lines . repeat ( 10 ) , 'CrossFile.java' , tempFolder , {
44
+ preview : false ,
45
+ } )
44
46
const myCurrentEditor = await openATextEditorWithText ( '' , 'TargetFile.java' , tempFolder , {
45
47
preview : false ,
46
48
} )
47
49
const actual = await crossFile . fetchSupplementalContextForSrc ( myCurrentEditor , fakeCancellationToken )
48
50
assert . ok ( actual )
49
- assert . ok ( actual . supplementalContextItems . length === 3 )
50
-
51
- assert . strictEqual ( actual . supplementalContextItems [ 0 ] . content . split ( '\n' ) . length , 10 )
52
- assert . strictEqual ( actual . supplementalContextItems [ 1 ] . content . split ( '\n' ) . length , 10 )
53
- assert . strictEqual ( actual . supplementalContextItems [ 2 ] . content . split ( '\n' ) . length , 10 )
51
+ assert . ok ( actual . supplementalContextItems . length === crossFileContextConfig . topK )
52
+
53
+ assert . strictEqual (
54
+ actual . supplementalContextItems [ 0 ] . content . split ( '\n' ) . length ,
55
+ crossFileContextConfig . numberOfLinesEachChunk
56
+ )
57
+ assert . strictEqual (
58
+ actual . supplementalContextItems [ 1 ] . content . split ( '\n' ) . length ,
59
+ crossFileContextConfig . numberOfLinesEachChunk
60
+ )
61
+ assert . strictEqual (
62
+ actual . supplementalContextItems [ 2 ] . content . split ( '\n' ) . length ,
63
+ crossFileContextConfig . numberOfLinesEachChunk
64
+ )
54
65
}
55
66
56
67
it ( 'control group' , async function ( ) {
@@ -267,12 +278,12 @@ describe('crossFileContextUtil', function () {
267
278
assert . strictEqual ( chunks [ 1 ] . content , 'line_6\nline_7' )
268
279
} )
269
280
270
- it ( 'codewhisperer crossfile config should use 10 lines' , async function ( ) {
281
+ it ( 'codewhisperer crossfile config should use 50 lines' , async function ( ) {
271
282
const filePath = path . join ( tempFolder , 'file.txt' )
272
283
await toFile ( sampleFileOf60Lines , filePath )
273
284
274
285
const chunks = await crossFile . splitFileToChunks ( filePath , crossFileContextConfig . numberOfLinesEachChunk )
275
- assert . strictEqual ( chunks . length , 6 )
286
+ assert . strictEqual ( chunks . length , 2 )
276
287
} )
277
288
} )
278
289
} )
0 commit comments