import { plainTextToHtml } from './htmlUtils'; describe('htmlUtils', () => { test('should convert a plain text string to its HTML equivalent', () => { const testCases = [ [ '', '', ], [ 'line 1\nline 2', '
line 1
line 2
one
two
three
four
', ], [ '\n\n', 'one
', ], [ '\none\ntwo\n', 'one
two
one
two
', ], [ 'one\n\n\n\ntwo', 'one
two
', ], [ '', '<img onerror="http://downloadmalware.com"/>', ], ]; for (const t of testCases) { const [input, expected] = t; const actual = plainTextToHtml(input); expect(actual).toBe(expected); } }); });