@@ -255,5 +255,91 @@ describe('GitAnalyzer', () => {
255255 expect ( Array . isArray ( result ) ) . toBe ( true ) ;
256256 // Should handle malformed input gracefully
257257 } ) ;
258+
259+ it ( 'should parse name-status format correctly' , ( ) => {
260+ const diffOutput = 'M\tmodified-file.ts\nA\tnew-file.ts\nD\tdeleted-file.ts' ;
261+
262+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
263+ const result = ( gitAnalyzer as any ) . parseChangedFiles ( diffOutput ) ;
264+
265+ expect ( result ) . toHaveLength ( 3 ) ;
266+ expect ( result [ 0 ] ) . toEqual ( {
267+ path : 'modified-file.ts' ,
268+ status : 'modified' ,
269+ additions : 0 ,
270+ deletions : 0 ,
271+ diff : '' ,
272+ } ) ;
273+ expect ( result [ 1 ] ) . toEqual ( {
274+ path : 'new-file.ts' ,
275+ status : 'added' ,
276+ additions : 0 ,
277+ deletions : 0 ,
278+ diff : '' ,
279+ } ) ;
280+ expect ( result [ 2 ] ) . toEqual ( {
281+ path : 'deleted-file.ts' ,
282+ status : 'deleted' ,
283+ additions : 0 ,
284+ deletions : 0 ,
285+ diff : '' ,
286+ } ) ;
287+ } ) ;
288+ } ) ;
289+
290+ describe ( 'calculateLineCounts' , ( ) => {
291+ it ( 'should calculate additions and deletions from diff sections' , ( ) => {
292+ const files = [
293+ { path : 'test.ts' , status : 'modified' as const , additions : 0 , deletions : 0 , diff : '' } ,
294+ { path : 'other.ts' , status : 'added' as const , additions : 0 , deletions : 0 , diff : '' } ,
295+ ] ;
296+
297+ const diffOutput = `diff --git a/test.ts b/test.ts
298+ index 1234567..abcdefg 100644
299+ --- a/test.ts
300+ +++ b/test.ts
301+ @@ -1,3 +1,4 @@
302+ line1
303+ +line2
304+ line3
305+ -line4
306+ +line5
307+ diff --git a/other.ts b/other.ts
308+ new file mode 100644
309+ index 0000000..1234567
310+ --- /dev/null
311+ +++ b/other.ts
312+ @@ -0,0 +1,2 @@
313+ +new line 1
314+ +new line 2` ;
315+
316+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
317+ ( gitAnalyzer as any ) . calculateLineCounts ( files , diffOutput ) ;
318+
319+ expect ( files [ 0 ] . additions ) . toBe ( 2 ) ; // +line2, +line5
320+ expect ( files [ 0 ] . deletions ) . toBe ( 1 ) ; // -line4
321+ expect ( files [ 1 ] . additions ) . toBe ( 2 ) ; // +new line 1, +new line 2
322+ expect ( files [ 1 ] . deletions ) . toBe ( 0 ) ;
323+ } ) ;
324+
325+ it ( 'should handle files without matching diff sections' , ( ) => {
326+ const files = [
327+ { path : 'missing.ts' , status : 'modified' as const , additions : 0 , deletions : 0 , diff : '' } ,
328+ ] ;
329+
330+ const diffOutput = `diff --git a/other.ts b/other.ts
331+ index 1234567..abcdefg 100644
332+ --- a/other.ts
333+ +++ b/other.ts
334+ @@ -1,1 +1,2 @@
335+ line1
336+ +line2` ;
337+
338+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
339+ ( gitAnalyzer as any ) . calculateLineCounts ( files , diffOutput ) ;
340+
341+ expect ( files [ 0 ] . additions ) . toBe ( 0 ) ;
342+ expect ( files [ 0 ] . deletions ) . toBe ( 0 ) ;
343+ } ) ;
258344 } ) ;
259345} ) ;
0 commit comments