import preprocessEditorInput from './preprocessEditorInput'; describe('preprocessEditorInput', () => { test.each([ { label: 'Should add the correct original markup for a multi-line paragraph', originalHtml: `

Test
Testing...

`, source: 'Test
Testing...\n\nTest!', expected: (dom: Document) => { expect( dom.querySelector('p').getAttribute('data-original-markup'), ).toBe('Test
Testing...\n'); }, }, { label: 'Should add the correct original markup for a list', // Joplin lists don't have toplevel source-line and source-line-end attributes. // As such, preprocessEditorInput should fetch this information from the list items. originalHtml: ``, source: '- Testing...\n- Test', expected: (dom: Document) => { expect( dom.querySelector('ul').getAttribute('data-original-markup'), ).toBe('- Testing...\n- Test'); }, }, ])('should add a "data-original-markup" attribute to toplevel nodes: $label', ({ originalHtml, source, expected }) => { const dom = new DOMParser().parseFromString(originalHtml, 'text/html'); preprocessEditorInput(dom, source); expected(dom); }); });