import htmlUtils, { extractHtmlBody, htmlDocIsImageOnly, removeWrappingParagraphAndTrailingEmptyElements } from './htmlUtils'; describe('htmlUtils', () => { test('should strip off HTML', () => { const testCases = [ [ '', '', ], [ 'test', 'test', ], [ 'Joplin®', 'JoplinĀ®', ], [ '<b>test</b>', '<b>test</b>', ], ]; for (const t of testCases) { const [input, expected] = t; const actual = htmlUtils.stripHtml(input); expect(actual).toBe(expected); } }); test('should extract the HTML body', () => { const testCases: [string, string][] = [ [ 'Just testing', 'Just testing', ], [ '', '', ], [ '
Here is the bodySome text
', false, ], [ 'Test
', 'Test'], ['Testing
A test
', 'Testing
A test
'], ['Testing
Testing
Testing
', 'Testing
'], ['Testing
', 'Testing'], ['is
\n', 'is\n'], ])('should remove empty elements (case %#)', (before, expected) => { expect(removeWrappingParagraphAndTrailingEmptyElements(before)).toBe(expected); }); });