wisemapping-frontend/packages/mindplot/test/unit/import/TextImporterTestSuite.test.ts
2022-03-17 16:24:52 -03:00

26 lines
963 B
TypeScript

/* eslint-disable import/no-extraneous-dependencies */
import path from 'path';
import fs from 'fs';
import { test } from '@jest/globals';
import { exporterAssert, parseXMLFile } from './Helper';
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]);
describe('MM import test execution', () => {
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);
const importer = TextImporterFactory.create('mm', freemap);
await exporterAssert(testName, importer);
});
});