smartxml/test/test.ts

36 lines
853 B
TypeScript
Raw Normal View History

2023-10-20 15:38:44 +00:00
import { expect, tap } from '@push.rocks/tapbundle';
import * as smartxml from '../ts/index.js';
2020-10-24 15:47:12 +00:00
2020-10-24 16:39:37 +00:00
let testSmartxml: smartxml.SmartXml;
2020-10-24 21:03:51 +00:00
let testXml = `
<hello>
<wow>nice</wow>
</hello>
`;
2020-10-24 16:39:37 +00:00
2020-10-24 21:03:51 +00:00
tap.test('should create an instance', async () => {
2020-10-24 16:39:37 +00:00
testSmartxml = new smartxml.SmartXml();
});
tap.test('should create an xml string', async () => {
const xmlResult = testSmartxml.createXmlFromObject({
hello: {
2020-10-25 22:19:44 +00:00
"@_xlmns:teststring": "hellothere",
"@_xlmns:testnumber": 10,
2020-10-26 00:44:26 +00:00
wow: 'test',
url: [{loc: 3},{loc: 3}]
2020-10-24 16:39:37 +00:00
}
});
console.log(xmlResult);
2020-10-24 15:47:12 +00:00
});
2020-10-24 21:03:51 +00:00
tap.test('should parse an yml file', async () => {
const jsObject = testSmartxml.parseXmlToObject(testXml);
console.log(jsObject);
2023-10-20 15:38:44 +00:00
expect(typeof jsObject).toEqual('object');
expect(jsObject).property('hello').property('wow').toEqual('nice');
2020-10-24 21:03:51 +00:00
});
2020-10-24 16:39:37 +00:00
2020-10-24 15:47:12 +00:00
tap.start();