import { htmlToText, PARAGRAPH, wordDiff } from '../diff'; describe('wordDiff', () => { it('marks what a rewrite kept, added and dropped', () => { expect( wordDiff('A blue hoodie with a pocket', 'A blue cotton hoodie') ).toEqual([ { type: 'same', text: 'A blue' }, { type: 'add', text: 'cotton' }, { type: 'same', text: 'hoodie' }, { type: 'del', text: 'with a pocket' }, ]); }); it('reads a reflowed paragraph as unchanged', () => { expect(wordDiff('one two\nthree', 'one two three')).toEqual([ { type: 'same', text: 'one two three' }, ]); }); it('keeps paragraph breaks as words', () => { expect(wordDiff('one\n\ntwo', 'one\n\ntwo')).toEqual([ { type: 'same', text: `one ${PARAGRAPH} two` }, ]); }); it('shows an empty side whole', () => { expect(wordDiff('', 'new text')).toEqual([ { type: 'add', text: 'new text' }, ]); expect(wordDiff('old', '')).toEqual([{ type: 'del', text: 'old' }]); }); }); describe('htmlToText', () => { it('keeps blocks apart and drops the tags', () => { expect( htmlToText( '

One two

Three

' ) ).toBe('One two\n\nThree\n\nfour\n\nfive'); }); });