Skip to content

Commit 3d030b4

Browse files
committed
Moving diffs to fixture
1 parent 6f0e936 commit 3d030b4

2 files changed

Lines changed: 27 additions & 27 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export const simpleDiff = `diff --git a/src/file.ts b/src/file.ts
2+
index 1234567..abcdefg 100644
3+
--- a/src/file.ts
4+
+++ b/src/file.ts
5+
@@ -1,4 +1,4 @@
6+
export function hello() {
7+
- console.log('hello');
8+
+ console.log('hello world');
9+
}`
10+
11+
export const diffHeaders = `diff --git a/package.json b/package.json
12+
index 1111111..2222222 100644
13+
--- a/package.json
14+
+++ b/package.json
15+
@@ -1,5 +1,5 @@
16+
{
17+
"name": "test"
18+
}`;
19+
20+
export const diffNoAts = `diff --git a/file.txt b/file.txt
21+
index 1234567..abcdefg 100644
22+
--- a/file.txt
23+
+++ b/file.txt`;

src/test/common/sessionParsing.test.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
toFileLabel,
1212
SessionResponseLogChunk
1313
} from '../../../common/sessionParsing';
14+
import { diffHeaders, diffNoAts, simpleDiff } from './fixtures/gitdiff/sessionParsing';
1415

1516
describe('sessionParsing', function () {
1617
describe('parseSessionLogs()', function () {
@@ -209,17 +210,7 @@ another non-data line`;
209210

210211
describe('parseDiff()', function () {
211212
it('should parse diff content correctly', function () {
212-
const diffContent = `diff --git a/src/file.ts b/src/file.ts
213-
index 1234567..abcdefg 100644
214-
--- a/src/file.ts
215-
+++ b/src/file.ts
216-
@@ -1,4 +1,4 @@
217-
export function hello() {
218-
- console.log('hello');
219-
+ console.log('hello world');
220-
}`;
221-
222-
const result = parseDiff(diffContent);
213+
const result = parseDiff(simpleDiff);
223214

224215
assert(result);
225216
assert.strictEqual(result.fileA, '/src/file.ts');
@@ -229,16 +220,7 @@ index 1234567..abcdefg 100644
229220
});
230221

231222
it('should extract file paths from diff headers', function () {
232-
const diffContent = `diff --git a/package.json b/package.json
233-
index 1111111..2222222 100644
234-
--- a/package.json
235-
+++ b/package.json
236-
@@ -1,5 +1,5 @@
237-
{
238-
"name": "test"
239-
}`;
240-
241-
const result = parseDiff(diffContent);
223+
const result = parseDiff(diffHeaders);
242224

243225
assert(result);
244226
assert.strictEqual(result.fileA, '/package.json');
@@ -254,12 +236,7 @@ index 1111111..2222222 100644
254236
});
255237

256238
it('should handle diffs without @@ lines', function () {
257-
const diffContent = `diff --git a/file.txt b/file.txt
258-
index 1234567..abcdefg 100644
259-
--- a/file.txt
260-
+++ b/file.txt`;
261-
262-
const result = parseDiff(diffContent);
239+
const result = parseDiff(diffNoAts);
263240

264241
assert.strictEqual(result, undefined);
265242
});

0 commit comments

Comments
 (0)