| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d9be770 commit fe26afd
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,7 @@ describe("Diff", function() { | |||
| 12 | 12 | ||
| 13 | 13 | before(function(done) { | |
| 14 | 14 | var test = this; | |
| 15 | + var newFilePath = path.join(path.resolve("test/repos/workdir"), "wddiff.txt"); | ||
| 15 | 16 | ||
| 16 | 17 | return Repository.open(reposPath).then(function(repository) { | |
| 17 | 18 | test.repository = repository; | |
@@ -26,7 +27,15 @@ describe("Diff", function() { | |||
| 26 | 27 | ||
| 27 | 28 | return commit.getDiff().then(function(diff) { | |
| 28 | 29 | test.diff = diff; | |
| 29 | - done(); | ||
| 30 | + fs.writeFileSync(newFilePath, "1 line\n2 line\n3 line\n\n4"); | ||
| 31 | + | ||
| 32 | + exec("git add wddiff.txt", {cwd: path.resolve("test/repos/workdir")}, function() { | ||
| 33 | + Diff.treeToWorkdirWithIndex(test.repository, test.masterCommitTree, null) | ||
| 34 | + .then(function(workdirDiff) { | ||
| 35 | + test.workdirDiff = workdirDiff; | ||
| 36 | + done(); | ||
| 37 | + }); | ||
| 38 | + }); | ||
| 30 | 39 | }); | |
| 31 | 40 | }); | |
| 32 | 41 | }); | |
@@ -64,25 +73,14 @@ describe("Diff", function() { | |||
| 64 | 73 | assert.equal(lines[3].contentLen(), 162); | |
| 65 | 74 | }); | |
| 66 | 75 | ||
| 67 | - it("can diff the workdir with index", function(done) { | ||
| 68 | - var test = this; | ||
| 69 | - var newFilePath = path.join(path.resolve("test/repos/workdir"), "wddiff.txt"); | ||
| 70 | - | ||
| 71 | - fs.writeFileSync(newFilePath, "1 line\n2 line\n3 line\n\n4"); | ||
| 76 | + it("can diff the workdir with index", function() { | ||
| 77 | + var patches = this.workdirDiff.patches(); | ||
| 78 | + assert.equal(patches.length, 1); | ||
| 72 | 79 | ||
| 73 | - exec("git add wddiff.txt", {cwd: path.resolve("test/repos/workdir")}, function() { | ||
| 74 | - Diff.treeToWorkdirWithIndex(test.repository, test.masterCommitTree, null) | ||
| 75 | - .then(function(workdirDiff) { | ||
| 76 | - var patches = workdirDiff.patches(); | ||
| 77 | - assert.equal(patches.length, 1); | ||
| 80 | + var hunks = patches[0].hunks(); | ||
| 81 | + assert.equal(hunks.length, 1); | ||
| 78 | 82 | ||
| 79 | - var hunks = patches[0].hunks(); | ||
| 80 | - assert.equal(hunks.length, 1); | ||
| 81 | - | ||
| 82 | - var lines = hunks[0].lines(); | ||
| 83 | - assert.equal(lines[0].content(), "1 line\n"); | ||
| 84 | - done(); | ||
| 85 | - }); | ||
| 86 | - }); | ||
| 83 | + var lines = hunks[0].lines(); | ||
| 84 | + assert.equal(lines[0].content(), "1 line\n"); | ||
| 87 | 85 | }); | |
| 88 | 86 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments