一些检查失败了
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
43 行
1.8 KiB
TypeScript
43 行
1.8 KiB
TypeScript
import '../../testing/test-utils';
|
|
import '../../testing/dom-test-environment';
|
|
import InteropService_Importer_OneNote from './InteropService_Importer_OneNote';
|
|
import Setting from '../../models/Setting';
|
|
|
|
describe('InteropService_Importer_OneNote.postprocessHtml', () => {
|
|
it.each([
|
|
{
|
|
label: 'when links are in an invalid/unsupported format',
|
|
before: '<a href="onenote:///some/unsupported/uri/">Test</a>',
|
|
after: '<a href="onenote:///some/unsupported/uri/">Test</a>',
|
|
},
|
|
{
|
|
label: 'when links are valid',
|
|
before: '<a href="onenote:///some/uri/#Page%202§ion-id={some-section-id-here}&page-id={12345678-9012-3456-7890-123456789012}&end">Test</a>',
|
|
after: '<a href="test.html">Test</a>',
|
|
idMap: (parentDir: string) => new Map([
|
|
['{12345678-9012-3456-7890-123456789012}', { path: `${parentDir}/test.html` }],
|
|
]),
|
|
},
|
|
])('should correctly convert onenote: protocol links $label', async ({ before, after, idMap = () => new Map() }) => {
|
|
// The importer needs a parent directory. Usually, this directory would contain the intermediate
|
|
// HTML files generated by the importer or the input files. However, for this test, there are no
|
|
// input or intermediate files, so use the empty temp directory created by the test setup logic:
|
|
const testImportDirectory = Setting.value('tempDir');
|
|
|
|
const importer = new InteropService_Importer_OneNote();
|
|
await importer.init(testImportDirectory, {
|
|
domParser: new DOMParser(),
|
|
xmlSerializer: new XMLSerializer(),
|
|
});
|
|
|
|
const normalizeOutput = (output: string) => {
|
|
return new DOMParser().parseFromString(output, 'text/html').body.innerHTML;
|
|
};
|
|
expect(
|
|
normalizeOutput((await importer.postprocessGeneratedHtml_(before, testImportDirectory, idMap(testImportDirectory))).html),
|
|
).toBe(
|
|
normalizeOutput(after),
|
|
);
|
|
});
|
|
});
|