一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
40 行
1.4 KiB
TypeScript
40 行
1.4 KiB
TypeScript
import preprocessEditorInput from './preprocessEditorInput';
|
|
|
|
describe('preprocessEditorInput', () => {
|
|
test.each([
|
|
{
|
|
label: 'Should add the correct original markup for a multi-line paragraph',
|
|
originalHtml: `<p
|
|
class="maps-to-line"
|
|
source-line="0"
|
|
source-line-end="2"
|
|
>Test<br>Testing...</p>`,
|
|
source: 'Test<br>Testing...\n\nTest!',
|
|
expected: (dom: Document) => {
|
|
expect(
|
|
dom.querySelector('p').getAttribute('data-original-markup'),
|
|
).toBe('Test<br>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: `<ul>
|
|
<li class="maps-to-line" source-line="0" source-line-end="1">Testing...</li>
|
|
<li class="maps-to-line" source-line="1" source-line-end="2">Test.</li>
|
|
</ul>`,
|
|
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);
|
|
});
|
|
});
|