Skip to content

Commit 078167c

Browse files
Add test for case where oldHeader and newHeader are omitted in structuredPatch call (#600)
1 parent de70072 commit 078167c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/patch/create.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,21 @@ describe('patch/create', function() {
881881
);
882882
});
883883

884+
it('sets oldHeader and newHeader to undefined if they are not provided', function() {
885+
const res = structuredPatch(
886+
'oldfile', 'newfile',
887+
'line2\nline3\nline4\n', 'line2\nline3\nline5'
888+
);
889+
expect(res).to.eql({
890+
oldFileName: 'oldfile', newFileName: 'newfile',
891+
oldHeader: undefined, newHeader: undefined,
892+
hunks: [{
893+
oldStart: 1, oldLines: 3, newStart: 1, newLines: 3,
894+
lines: [' line2', ' line3', '-line4', '+line5', '\\ No newline at end of file']
895+
}]
896+
});
897+
});
898+
884899
describe('given options.maxEditLength', function() {
885900
const options = { maxEditLength: 1 };
886901

0 commit comments

Comments
 (0)