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: 'Test', after: 'Test', }, { label: 'when links are valid', before: 'Test', after: 'Test', 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), ); }); });