smartxml/test/test.ts
2023-10-20 17:38:44 +02:00

36 lines
853 B
TypeScript

import { expect, tap } from '@push.rocks/tapbundle';
import * as smartxml from '../ts/index.js';
let testSmartxml: smartxml.SmartXml;
let testXml = `
<hello>
<wow>nice</wow>
</hello>
`;
tap.test('should create an instance', async () => {
testSmartxml = new smartxml.SmartXml();
});
tap.test('should create an xml string', async () => {
const xmlResult = testSmartxml.createXmlFromObject({
hello: {
"@_xlmns:teststring": "hellothere",
"@_xlmns:testnumber": 10,
wow: 'test',
url: [{loc: 3},{loc: 3}]
}
});
console.log(xmlResult);
});
tap.test('should parse an yml file', async () => {
const jsObject = testSmartxml.parseXmlToObject(testXml);
console.log(jsObject);
expect(typeof jsObject).toEqual('object');
expect(jsObject).property('hello').property('wow').toEqual('nice');
});
tap.start();