wisemapping-frontend/packages/mindplot/test/unit/import/TextImporterTestSuite.test.ts

28 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-03-10 16:26:24 +01:00
/* eslint-disable import/no-extraneous-dependencies */
2022-03-08 18:30:34 +01:00
import path from 'path';
import fs from 'fs';
import { test } from '@jest/globals';
import { exporterAssert, parseXMLFile } from './Helper';
2022-03-08 18:30:34 +01:00
import FreemindMap from '../../../src/components/export/freemind/Map';
import TextImporterFactory from '../../../src/components/import/TextImporterFactory';
const testNames = fs
.readdirSync(path.resolve(__dirname, './input/'))
.map((filename: string) => filename.split('.')[0]);
2022-05-25 04:14:28 +02:00
describe('package/', () => {
2022-03-08 18:30:34 +01:00
test.each(testNames)('Importing %p suite', async (testName: string) => {
// load freemap...
const freemapPath = path.resolve(__dirname, `./input/${testName}.mm`);
const mapDocument = parseXMLFile(freemapPath, 'text/xml');
const freemap: FreemindMap = new FreemindMap().loadFromDom(mapDocument);
2022-03-22 16:34:27 +01:00
const freemapXml = freemap.toXml();
const freemapStr = new XMLSerializer().serializeToString(freemapXml);
2022-03-08 18:30:34 +01:00
2022-03-22 16:34:27 +01:00
const importer = TextImporterFactory.create('mm', freemapStr);
2022-03-08 18:30:34 +01:00
2022-03-10 16:26:24 +01:00
await exporterAssert(testName, importer);
2022-03-08 18:30:34 +01:00
});
});