Skip to content

Commit 045c346

Browse files
Add test of how diffWordsWithSpace handles Windows-style newlines (#499)
1 parent f925d4c commit 045c346

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/diff/word.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ describe('WordDiff', function() {
249249
// #211
250250
const diffResult2 = diffWordsWithSpace('A\n\nB\n', 'A\nB\n');
251251
expect(convertChangesToXML(diffResult2)).to.equal('A\n<del>\n</del>B\n');
252+
// Windows-style newlines should also get a single token
253+
const diffResult3 = diffWordsWithSpace('foo\r\nbar', 'foo \r\n\r\n\r\nbar');
254+
expect(convertChangesToXML(diffResult3)).to.equal('foo<ins> </ins>\r\n<ins>\r\n\r\n</ins>bar');
255+
const diffResult4 = diffWordsWithSpace('A\r\n\r\nB\r\n', 'A\r\nB\r\n');
256+
expect(convertChangesToXML(diffResult4)).to.equal('A\r\n<del>\r\n</del>B\r\n');
252257
});
253258

254259
it('should perform async operations', function(done) {

0 commit comments

Comments
 (0)