mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
Add marker for expansion hunks
This commit is contained in:
@@ -289,9 +289,12 @@ describe("with hunks the diff expander", () => {
|
||||
expect(fetchMock.done()).toBe(true);
|
||||
expect(newFile!.hunks!.length).toBe(oldHunkCount + 1);
|
||||
expect(newFile!.hunks![1]).toBe(expandedHunk);
|
||||
const newHunk = newFile!.hunks![2].changes;
|
||||
expect(newHunk.length).toBe(1);
|
||||
expect(newHunk[0].content).toBe("new line 1");
|
||||
|
||||
const newHunk = newFile!.hunks![2];
|
||||
expect(newHunk.changes.length).toBe(1);
|
||||
expect(newHunk.changes[0].content).toBe("new line 1");
|
||||
expect(newHunk.expansion).toBe(true);
|
||||
|
||||
expect(newFile!.hunks![3]).toBe(subsequentHunk);
|
||||
});
|
||||
it("should create new hunk with new line from api client at the top", async () => {
|
||||
@@ -313,16 +316,18 @@ describe("with hunks the diff expander", () => {
|
||||
expect(newFile!.hunks![0]).toBe(preceedingHunk);
|
||||
expect(newFile!.hunks![2]).toBe(expandedHunk);
|
||||
|
||||
expect(newFile!.hunks![1].changes.length).toBe(5);
|
||||
expect(newFile!.hunks![1].changes[0].content).toBe("new line 9");
|
||||
expect(newFile!.hunks![1].changes[0].oldLineNumber).toBe(9);
|
||||
expect(newFile!.hunks![1].changes[0].newLineNumber).toBe(9);
|
||||
expect(newFile!.hunks![1].changes[1].content).toBe("new line 10");
|
||||
expect(newFile!.hunks![1].changes[1].oldLineNumber).toBe(10);
|
||||
expect(newFile!.hunks![1].changes[1].newLineNumber).toBe(10);
|
||||
expect(newFile!.hunks![1].changes[4].content).toBe("new line 13");
|
||||
expect(newFile!.hunks![1].changes[4].oldLineNumber).toBe(13);
|
||||
expect(newFile!.hunks![1].changes[4].newLineNumber).toBe(13);
|
||||
const newHunk = newFile!.hunks![1];
|
||||
expect(newHunk.changes.length).toBe(5);
|
||||
expect(newHunk.changes[0].content).toBe("new line 9");
|
||||
expect(newHunk.changes[0].oldLineNumber).toBe(9);
|
||||
expect(newHunk.changes[0].newLineNumber).toBe(9);
|
||||
expect(newHunk.changes[1].content).toBe("new line 10");
|
||||
expect(newHunk.changes[1].oldLineNumber).toBe(10);
|
||||
expect(newHunk.changes[1].newLineNumber).toBe(10);
|
||||
expect(newHunk.changes[4].content).toBe("new line 13");
|
||||
expect(newHunk.changes[4].oldLineNumber).toBe(13);
|
||||
expect(newHunk.changes[4].newLineNumber).toBe(13);
|
||||
expect(newHunk.expansion).toBe(true);
|
||||
});
|
||||
it("should set fully expanded to true if expanded completely", async () => {
|
||||
const oldHunkCount = diffExpander.hunkCount();
|
||||
|
||||
@@ -133,7 +133,8 @@ class DiffExpander {
|
||||
newStart: minNewLineNumberOfNewHunk,
|
||||
oldLines: lines.length,
|
||||
newLines: lines.length,
|
||||
changes: newChanges
|
||||
changes: newChanges,
|
||||
expansion: true
|
||||
};
|
||||
const newHunks: Hunk[] = [];
|
||||
this.file.hunks!.forEach((oldHunk: Hunk, i: number) => {
|
||||
@@ -178,6 +179,7 @@ class DiffExpander {
|
||||
newStart: maxNewLineNumberFromPrecedingHunk + 1,
|
||||
oldLines: lines.length,
|
||||
newLines: lines.length,
|
||||
expansion: true,
|
||||
fullyExpanded: requestedLines < 0 || lines.length < requestedLines
|
||||
};
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ export type Hunk = {
|
||||
oldLines?: number;
|
||||
newLines?: number;
|
||||
fullyExpanded?: boolean;
|
||||
expansion?: boolean;
|
||||
};
|
||||
|
||||
export type ChangeType = "insert" | "delete" | "normal" | "conflict";
|
||||
|
||||
Reference in New Issue
Block a user