Skip to content

Commit f1b1feb

Browse files
committed
Add tests for supporting stripTrailingCr in createPatch
1 parent 2851161 commit f1b1feb

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/patch/create.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,45 @@ describe('patch/create', function() {
705705
});
706706
});
707707

708+
describe('stripTrailingCr', function() {
709+
it('stripTrailingCr: false', function() {
710+
const expectedResult =
711+
'===================================================================\n'
712+
+ '--- foo\n'
713+
+ '+++ bar\n'
714+
+ '@@ -1,2 +1,2 @@\n'
715+
+ '\-line\n'
716+
+ '\+line\r\n'
717+
+ '\ line\n'
718+
+ '\\ No newline at end of file\n';
719+
expect(createTwoFilesPatch(
720+
'foo',
721+
'bar',
722+
'line\nline',
723+
'line\r\nline',
724+
undefined,
725+
undefined,
726+
{stripTrailingCr: false}
727+
)).to.equal(expectedResult);
728+
});
729+
730+
it('stripTrailingCr: true', function() {
731+
const expectedResult =
732+
'===================================================================\n'
733+
+ '--- foo\n'
734+
+ '+++ bar\n';
735+
expect(createTwoFilesPatch(
736+
'foo',
737+
'bar',
738+
'line\nline',
739+
'line\r\nline',
740+
undefined,
741+
undefined,
742+
{stripTrailingCr: true}
743+
)).to.equal(expectedResult);
744+
});
745+
});
746+
708747
describe('#structuredPatch', function() {
709748
it('should handle files with the last line changed', function() {
710749
const res = structuredPatch(

0 commit comments

Comments
 (0)