33 lines
919 B
TypeScript
33 lines
919 B
TypeScript
import { expect, tap } from '@push.rocks/tapbundle';
|
|
import * as smartxml from '../ts/index.js';
|
|
|
|
let testSmartxml: smartxml.SmartXml;
|
|
let testXml = '';
|
|
|
|
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);
|
|
testXml = xmlResult;
|
|
});
|
|
|
|
tap.test('should parse an yml file', async () => {
|
|
const jsObject = testSmartxml.parseXmlToObject(testXml);
|
|
// console.log(JSON.stringify(jsObject, null, 2));
|
|
expect(typeof jsObject).toEqual('object');
|
|
expect(jsObject).arrayItem(1).property('hello').arrayItem(0).property('wow').arrayItem(0).property('#text').toEqual('test');
|
|
});
|
|
|
|
|
|
tap.start();
|