File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -737,6 +737,24 @@ describe('patch/apply', function() {
737
737
738
738
expect ( applyPatch ( oldContent , patch ) ) . to . equal ( newContent ) ;
739
739
} ) ;
740
+
741
+ // Regression test based on bug https://github.com/kpdecker/jsdiff/issues/177
742
+ it ( 'should correctly apply a patch that truncates an entire file' , function ( ) {
743
+ const patch = parsePatch (
744
+ '===================================================================\n'
745
+ + '--- index.js\n'
746
+ + '+++ index.js\n'
747
+ + '@@ -1,3 +1,0 @@\n'
748
+ + '-this\n'
749
+ + '-\n'
750
+ + '-tos\n'
751
+ + '\\ No newline at end of file\n'
752
+ ) ;
753
+ const fileContents = 'this\n\ntos' ;
754
+
755
+ expect ( applyPatch ( fileContents , patch ) )
756
+ . to . equal ( '' ) ;
757
+ } ) ;
740
758
} ) ;
741
759
742
760
describe ( '#applyPatches' , function ( ) {
You can’t perform that action at this time.
0 commit comments