Skip to content

Commit 9924575

Browse files
committed
Add tests for supporting stripTrailingCr in createPatch
1 parent 8a34122 commit 9924575

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
@@ -631,6 +631,45 @@ describe('patch/create', function() {
631631
const diffResult = createTwoFilesPatch('foo', 'bar', '', '');
632632
expect(diffResult).to.equal(expectedResult);
633633
});
634+
635+
describe('stripTrailingCr', function() {
636+
it('stripTrailingCr: false', function() {
637+
const expectedResult =
638+
'===================================================================\n'
639+
+ '--- foo\n'
640+
+ '+++ bar\n'
641+
+ '@@ -1,2 +1,2 @@\n'
642+
+ '\-line\n'
643+
+ '\+line\r\n'
644+
+ '\ line\n'
645+
+ '\\ No newline at end of file\n';
646+
expect(createTwoFilesPatch(
647+
'foo',
648+
'bar',
649+
'line\nline',
650+
'line\r\nline',
651+
undefined,
652+
undefined,
653+
{stripTrailingCr: false}
654+
)).to.equal(expectedResult);
655+
});
656+
657+
it('stripTrailingCr: true', function() {
658+
const expectedResult =
659+
'===================================================================\n'
660+
+ '--- foo\n'
661+
+ '+++ bar\n';
662+
expect(createTwoFilesPatch(
663+
'foo',
664+
'bar',
665+
'line\nline',
666+
'line\r\nline',
667+
undefined,
668+
undefined,
669+
{stripTrailingCr: true}
670+
)).to.equal(expectedResult);
671+
});
672+
});
634673
});
635674

636675
describe('#structuredPatch', function() {

0 commit comments

Comments
 (0)