From bed093c91e4d15cd459fab7c98fc6932db1e34d5 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Thu, 5 Sep 2024 15:02:17 +0100 Subject: [PATCH] Add test for bug https://github.com/kpdecker/jsdiff/issues/553 --- test/diff/word.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/diff/word.js b/test/diff/word.js index f81a4e45..418a8ae5 100644 --- a/test/diff/word.js +++ b/test/diff/word.js @@ -31,6 +31,34 @@ describe('WordDiff', function() { '.' ]); }); + + // Test for bug reported at https://github.com/kpdecker/jsdiff/issues/553 + it('should treat numbers as part of a word if not separated by whitespace or punctuation', () => { + expect( + wordDiff.tokenize( + 'Tea Too, also known as T2, had revenue of 57m AUD in 2012-13.' + ) + ).to.deep.equal([ + 'Tea ', + ' Too', + ', ', + ' also ', + ' known ', + ' as ', + ' T2', + ', ', + ' had ', + ' revenue ', + ' of ', + ' 57m ', + ' AUD ', + ' in ', + ' 2012', + '-', + '13', + '.' + ]); + }); }); describe('#diffWords', function() {