mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-06 03:53:59 +02:00
Add more unit tests
This commit is contained in:
parent
4bd1322941
commit
0bda93d4c3
@ -223,6 +223,24 @@ func TestModifyPatchForRange(t *testing.T) {
|
|||||||
-last line
|
-last line
|
||||||
\ No newline at end of file
|
\ No newline at end of file
|
||||||
+last line
|
+last line
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "add newline to end of file, reversed",
|
||||||
|
filename: "filename",
|
||||||
|
firstLineIndex: -100,
|
||||||
|
lastLineIndex: 100,
|
||||||
|
reverse: true,
|
||||||
|
diffText: addNewlineToEndOfFile,
|
||||||
|
expected: `--- a/filename
|
||||||
|
+++ b/filename
|
||||||
|
@@ -60,4 +60,4 @@ grape
|
||||||
|
...
|
||||||
|
...
|
||||||
|
...
|
||||||
|
-last line
|
||||||
|
\ No newline at end of file
|
||||||
|
+last line
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -240,6 +258,24 @@ func TestModifyPatchForRange(t *testing.T) {
|
|||||||
-last line
|
-last line
|
||||||
+last line
|
+last line
|
||||||
\ No newline at end of file
|
\ No newline at end of file
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "remove newline from end of file, reversed",
|
||||||
|
filename: "filename",
|
||||||
|
firstLineIndex: -100,
|
||||||
|
lastLineIndex: 100,
|
||||||
|
reverse: true,
|
||||||
|
diffText: removeNewlinefromEndOfFile,
|
||||||
|
expected: `--- a/filename
|
||||||
|
+++ b/filename
|
||||||
|
@@ -60,4 +60,4 @@ grape
|
||||||
|
...
|
||||||
|
...
|
||||||
|
...
|
||||||
|
-last line
|
||||||
|
+last line
|
||||||
|
\ No newline at end of file
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -255,6 +291,24 @@ func TestModifyPatchForRange(t *testing.T) {
|
|||||||
...
|
...
|
||||||
...
|
...
|
||||||
-last line
|
-last line
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "remove newline from end of file, removal only, reversed",
|
||||||
|
filename: "filename",
|
||||||
|
firstLineIndex: 8,
|
||||||
|
lastLineIndex: 8,
|
||||||
|
reverse: true,
|
||||||
|
diffText: removeNewlinefromEndOfFile,
|
||||||
|
expected: `--- a/filename
|
||||||
|
+++ b/filename
|
||||||
|
@@ -60,5 +60,4 @@ grape
|
||||||
|
...
|
||||||
|
...
|
||||||
|
...
|
||||||
|
-last line
|
||||||
|
last line
|
||||||
|
\ No newline at end of file
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -272,6 +326,23 @@ func TestModifyPatchForRange(t *testing.T) {
|
|||||||
last line
|
last line
|
||||||
+last line
|
+last line
|
||||||
\ No newline at end of file
|
\ No newline at end of file
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "remove newline from end of file, addition only, reversed",
|
||||||
|
filename: "filename",
|
||||||
|
firstLineIndex: 9,
|
||||||
|
lastLineIndex: 9,
|
||||||
|
reverse: true,
|
||||||
|
diffText: removeNewlinefromEndOfFile,
|
||||||
|
expected: `--- a/filename
|
||||||
|
+++ b/filename
|
||||||
|
@@ -60,3 +60,4 @@ grape
|
||||||
|
...
|
||||||
|
...
|
||||||
|
...
|
||||||
|
+last line
|
||||||
|
\ No newline at end of file
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -363,6 +434,20 @@ func TestModifyPatchForRange(t *testing.T) {
|
|||||||
@@ -0,0 +1,1 @@
|
@@ -0,0 +1,1 @@
|
||||||
+new line
|
+new line
|
||||||
\ No newline at end of file
|
\ No newline at end of file
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "adding a new line to a previously empty file, reversed",
|
||||||
|
filename: "newfile",
|
||||||
|
firstLineIndex: -100,
|
||||||
|
lastLineIndex: 100,
|
||||||
|
diffText: addNewlineToPreviouslyEmptyFile,
|
||||||
|
reverse: true,
|
||||||
|
expected: `--- a/newfile
|
||||||
|
+++ b/newfile
|
||||||
|
@@ -0,0 +1,1 @@
|
||||||
|
+new line
|
||||||
|
\ No newline at end of file
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user