chore: Push unit test files
Some checks failed
/ test (push) Has been cancelled

This commit is contained in:
2026-02-03 08:43:03 +00:00
parent 6e391bc213
commit b7e97a2ef8

View File

@@ -1,4 +1,4 @@
import { parseDiffOutput, countDiffStats } from '../../src/utils/diff-utils';
import { parseDiffOutput, countDiffStats } from '../../src/utils/git-utils';
describe('parseDiffOutput', () => {
it('should parse empty diff', () => {
@@ -7,81 +7,57 @@ describe('parseDiffOutput', () => {
});
it('should parse diff with one file', () => {
const diffOutput = `diff --git a/test.ts b/test.ts
index 1234567..89abcdef 100644
const diff = `diff --git a/test.ts b/test.ts
index 1234567..2345678 100644
--- a/test.ts
+++ b/test.ts
@@ -1,3 +1,4 @@
+import { useState } from 'react';
function App() {
return <div>Hello</div>;
}
@@ -5,3 +6,4 @@ function App() {
return <div>Hello</div>;
}
+// comment
@@ -1,3 +1,3 @@
-const a = 1;
+const a = 2;
const b = 3;
`;
const result = parseDiffOutput(diffOutput);
const result = parseDiffOutput(diff);
expect(result.length).toBe(1);
expect(result[0].file).toBe('test.ts');
expect(result[0].additions).toBe(2);
expect(result[0].deletions).toBe(0);
});
it('should parse diff with multiple files', () => {
const diffOutput = `diff --git a/file1.ts b/file1.ts
index 1234567..89abcdef 100644
--- a/file1.ts
+++ b/file1.ts
@@ -1,2 +1,3 @@
+const x = 1;
line 1
diff --git a/file2.ts b/file2.ts
index abcdef1..2345678 100644
--- a/file2.ts
+++ b/file2.ts
const diff = `diff --git a/test.ts b/test.ts
index 1234567..2345678 100644
--- a/test.ts
+++ b/test.ts
@@ -1,3 +1,3 @@
-const a = 1;
+const a = 2;
const b = 3;
diff --git a/other.ts b/other.ts
index 1234567..2345678 100644
--- a/other.ts
+++ b/other.ts
@@ -1,2 +1,2 @@
-old line
+new line
line 2
-const x = 1;
+const x = 2;
`;
const result = parseDiffOutput(diffOutput);
const result = parseDiffOutput(diff);
expect(result.length).toBe(2);
expect(result[0].file).toBe('file1.ts');
expect(result[1].file).toBe('file2.ts');
expect(result[0].additions).toBe(1);
expect(result[1].additions).toBe(1);
expect(result[1].deletions).toBe(1);
});
});
describe('countDiffStats', () => {
it('should count additions and deletions', () => {
const diffContent = `diff --git a/test.ts b/test.ts
@@ -1,3 +1,4 @@
+import { useState } from 'react';
function App() {
return <div>Hello</div>;
}
@@ -5,3 +6,4 @@ function App() {
return <div>Hello</div>;
}
+// comment
const diff = `diff --git a/test.ts b/test.ts
+const a = 1;
-const b = 2;
+const c = 3;
`;
const stats = countDiffStats(diffContent);
expect(stats.additions).toBe(2);
expect(stats.deletions).toBe(0);
expect(stats.files).toBe(1);
const result = countDiffStats(diff);
expect(result.additions).toBe(2);
expect(result.deletions).toBe(1);
});
it('should handle empty diff', () => {
const stats = countDiffStats('');
expect(stats.additions).toBe(0);
expect(stats.deletions).toBe(0);
expect(stats.files).toBe(1);
const result = countDiffStats('');
expect(result.additions).toBe(0);
expect(result.deletions).toBe(0);
});
});