From ec6a5779b2b237c5585817994ce1fd75a1ba2a39 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Mon, 7 Apr 2025 11:42:42 +0100 Subject: [PATCH] Add test for case where oldHeader and newHeader are omitted in structuredPatch call --- test/patch/create.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/patch/create.js b/test/patch/create.js index d4cdaf76..469f8df1 100644 --- a/test/patch/create.js +++ b/test/patch/create.js @@ -881,6 +881,21 @@ describe('patch/create', function() { ); }); + it('sets oldHeader and newHeader to undefined if they are not provided', function() { + const res = structuredPatch( + 'oldfile', 'newfile', + 'line2\nline3\nline4\n', 'line2\nline3\nline5' + ); + expect(res).to.eql({ + oldFileName: 'oldfile', newFileName: 'newfile', + oldHeader: undefined, newHeader: undefined, + hunks: [{ + oldStart: 1, oldLines: 3, newStart: 1, newLines: 3, + lines: [' line2', ' line3', '-line4', '+line5', '\\ No newline at end of file'] + }] + }); + }); + describe('given options.maxEditLength', function() { const options = { maxEditLength: 1 };