FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add additional tests for Staging, testing cases where no newline in EOF. · thedaniel/nodegit@7ea9dfb · GitHub

Repository navigation

Commit 7ea9dfb

Browse files
committed
Add additional tests for Staging, testing cases where no newline in EOF.
1 parent b5d49a1 commit 7ea9dfb

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

‎test/tests/stage.js‎

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ describe("Stage", function() {
2828
return fse.remove(test.repository.workdir());
2929
});
3030

31-
function stagingTest(staging) {
32-
var fileContent = "One line of text\n" +
31+
function stagingTest(staging, newFileContent) {
32+
var fileContent = newFileContent ||
33+
"One line of text\n" +
3334
"Two lines of text\n"+
3435
"Three lines of text\n"+
3536
"Four lines of text\n"+
@@ -137,7 +138,7 @@ function stagingTest(staging) {
137138
return test.repository.getBlob(pathOid);
138139
})
139140
.then(function(resultFileContents) {
140-
assert.equal(resultFileContents, stagedFile);
141+
assert.equal(resultFileContents.toString(), stagedFile);
141142
});
142143
}
143144

@@ -147,4 +148,38 @@ function stagingTest(staging) {
147148
it("can unstage selected lines", function() {
148149
return stagingTest(false);
149150
});
151+
152+
//This is used to test cases where there are no newline at EOF
153+
var newlineEofTestFileContent =
154+
"One line of text\n" +
155+
"Two lines of text\n"+
156+
"Three lines of text\n"+
157+
"Four lines of text\n"+
158+
"Five lines of text\n"+
159+
"Six lines of text\n"+
160+
"Seven lines of text\n"+
161+
"Eight lines of text\n"+
162+
"Nine lines of text\n"+
163+
"Ten lines of text\n"+
164+
"Eleven lines of text\n"+
165+
"Twelve lines of text\n"+
166+
"Thirteen lines of text\n"+
167+
"Fourteen lines of text\n"+
168+
"Fifteen lines of text";
169+
it("can stage last line with no newline at EOF", function() {
170+
return stagingTest(true, newlineEofTestFileContent);
171+
});
172+
it("can unstage last line with no newline at EOF", function() {
173+
return stagingTest(false, newlineEofTestFileContent);
174+
});
175+
it("can stage second to last line with no newline at EOF", function() {
176+
var newlineEofTestFileContent2 = newlineEofTestFileContent +
177+
"\nSixteen lines of text\nSeventeen lines of text\nEighteen lines of text";
178+
return stagingTest(true, newlineEofTestFileContent2);
179+
});
180+
it("can unstage second to last line with no newline at EOF", function() {
181+
var newlineEofTestFileContent2 = newlineEofTestFileContent +
182+
"\nSixteen lines of text\nSeventeen lines of text\nEighteen lines of text";
183+
return stagingTest(false, newlineEofTestFileContent2);
184+
});
150185
});

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL