import htmlUtils, { extractHtmlBody, htmlDocIsImageOnly } 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 body', 'Here is the body', ], ]; for (const [input, expected] of testCases) { const actual = extractHtmlBody(input); expect(actual).toBe(expected); } }); test('should tell if an HTML document is an image only', () => { const testCases: [string, boolean][] = [ [ // This is the kind of HTML that's pasted when copying an image from Chrome '\n', true, ], [ '', false, ], [ '', true, ], [ '', false, ], [ 'Some text
', false, ], [ ' Some text', false, ], ]; for (const [input, expected] of testCases) { const actual = htmlDocIsImageOnly(input); expect(actual).toBe(expected); } }); });