@@ -89,6 +89,22 @@ describe('patch/create', function() {
89
89
+ '+line4\n' ) ;
90
90
} ) ;
91
91
92
+ it ( 'should output "no newline" at end of file message on both missing nl' , function ( ) {
93
+ expect ( createPatch ( 'test' , 'line1\nline2\nline3\nline4' , 'line1\nline2\nline3\nline44' , 'header1' , 'header2' ) ) . to . equal (
94
+ 'Index: test\n'
95
+ + '===================================================================\n'
96
+ + '--- test\theader1\n'
97
+ + '+++ test\theader2\n'
98
+ + '@@ -1,4 +1,4 @@\n'
99
+ + ' line1\n'
100
+ + ' line2\n'
101
+ + ' line3\n'
102
+ + '-line4\n'
103
+ + '\\ No newline at end of file\n'
104
+ + '+line44\n'
105
+ + '\\ No newline at end of file\n' ) ;
106
+ } ) ;
107
+
92
108
it ( 'should output "no newline" at end of file message on context missing nl' , function ( ) {
93
109
expect ( createPatch ( 'test' , 'line11\nline2\nline3\nline4' , 'line1\nline2\nline3\nline4' , 'header1' , 'header2' ) ) . to . equal (
94
110
'Index: test\n'
@@ -104,6 +120,33 @@ describe('patch/create', function() {
104
120
+ '\\ No newline at end of file\n' ) ;
105
121
} ) ;
106
122
123
+ it ( 'should output only one "no newline" at end of file message on empty file' , function ( ) {
124
+ expect ( createPatch ( 'test' , '' , 'line1\nline2\nline3\nline4' , 'header1' , 'header2' ) ) . to . equal (
125
+ 'Index: test\n'
126
+ + '===================================================================\n'
127
+ + '--- test\theader1\n'
128
+ + '+++ test\theader2\n'
129
+ + '@@ -1,0 +1,4 @@\n'
130
+ + '\\ No newline at end of file\n'
131
+ + '+line1\n'
132
+ + '+line2\n'
133
+ + '+line3\n'
134
+ + '+line4\n'
135
+ + '\\ No newline at end of file\n' ) ;
136
+
137
+ expect ( createPatch ( 'test' , 'line1\nline2\nline3\nline4' , '' , 'header1' , 'header2' ) ) . to . equal (
138
+ 'Index: test\n'
139
+ + '===================================================================\n'
140
+ + '--- test\theader1\n'
141
+ + '+++ test\theader2\n'
142
+ + '@@ -1,4 +1,0 @@\n'
143
+ + '-line1\n'
144
+ + '-line2\n'
145
+ + '-line3\n'
146
+ + '-line4\n'
147
+ + '\\ No newline at end of file\n' ) ;
148
+ } ) ;
149
+
107
150
it ( 'should not output no newline at end of file message when eof outside hunk' , function ( ) {
108
151
expect ( createPatch ( 'test' , 'line11\nline2\nline3\nline4\nline4\nline4\nline4' , 'line1\nline2\nline3\nline4\nline4\nline4\nline4' , 'header1' , 'header2' ) ) . to . equal (
109
152
'Index: test\n'
0 commit comments