Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Test that bottom-most line is selected after staging bottom-most line
Browse files Browse the repository at this point in the history
  • Loading branch information
kuychaco committed Nov 16, 2018
1 parent 1685484 commit 8be43e5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/models/patch/multi-file-patch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,35 @@ describe('MultiFilePatch', function() {
assert.deepEqual(nextSelectionRange.serialize(), [[11, 0], [11, Infinity]]);
});

describe('when the bottom-most changed row is selected', function() {
it('selects the bottom-most changed row of the new patch', function() {
const {multiFilePatch: lastMultiPatch} = multiFilePatchBuilder()
.addFilePatch(fp => {
fp.addHunk(h => h.unchanged('.').added('0', '1', 'x').unchanged('.'));
fp.addHunk(h => h.unchanged('.').deleted('2').added('3').unchanged('.'));
})
.addFilePatch(fp => {
fp.addHunk(h => h.unchanged('.').deleted('4', '5', '6').unchanged('.'));
fp.addHunk(h => h.unchanged('.').added('7', '8 *').unchanged('.'));
})
.build();

const {multiFilePatch: nextMultiPatch} = multiFilePatchBuilder()
.addFilePatch(fp => {
fp.addHunk(h => h.unchanged('.').added('0', '1', 'x').unchanged('.'));
fp.addHunk(h => h.unchanged('.').deleted('2').added('3').unchanged('.'));
})
.addFilePatch(fp => {
fp.addHunk(h => h.unchanged('.').deleted('4', '5', '6').unchanged('.'));
fp.addHunk(h => h.unchanged('.').added('7').unchanged('.'));
})
.build();

const nextSelectionRange = nextMultiPatch.getNextSelectionRange(lastMultiPatch, new Set([16]));
assert.deepEqual(nextSelectionRange.serialize(), [[15, 0], [15, Infinity]]);
});
});

it('skips hunks that were completely selected', function() {
const {multiFilePatch: lastMultiPatch} = multiFilePatchBuilder()
.addFilePatch(fp => {
Expand Down

0 comments on commit 8be43e5

Please sign in to comment.