wisemapping-frontend/packages/mindplot/test/unit/export/PlainTextExporterTestSuite.test.ts

21 lines
842 B
TypeScript
Raw Normal View History

2021-12-30 01:37:58 +01:00
import PlainTextExporter from '../../../src/components/export/PlainTextExporter';
import Mindmap from '../../../src/components/model/Mindmap';
import fs from 'fs';
import path from 'path';
2021-12-30 02:10:28 +01:00
import XMLSerializerFactory from '../../../src/components/persistence/XMLSerializerFactory';
2021-12-30 01:37:58 +01:00
test('mindplot generation of simple maps', () => {
const parser = new DOMParser();
2021-12-30 02:10:28 +01:00
// Load DOM ...
const mapStream =fs.readFileSync(path.resolve(__dirname, './samples/welcome.xml'),{encoding: 'utf-8'});
2021-12-30 01:37:58 +01:00
const document = parser.parseFromString(mapStream.toString(), 'text/xml')
// Convert to mindmap ...
2021-12-30 02:10:28 +01:00
const serializer = XMLSerializerFactory.getSerializerFromDocument(document);
2021-12-30 01:37:58 +01:00
const mindmap:Mindmap = serializer.loadFromDom(document,'welcome');
const exporter = new PlainTextExporter(mindmap);
console.log(exporter.export());
});