fix(core): update
This commit is contained in:
parent
4fa7b5a4d2
commit
bb339b8c85
@ -9,7 +9,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web && tsbundle npm)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
|
14
test/test.ts
14
test/test.ts
@ -2,8 +2,13 @@ import { expect, tap } from '@pushrocks/tapbundle';
|
|||||||
import * as smartxml from '../ts/index';
|
import * as smartxml from '../ts/index';
|
||||||
|
|
||||||
let testSmartxml: smartxml.SmartXml;
|
let testSmartxml: smartxml.SmartXml;
|
||||||
|
let testXml = `
|
||||||
|
<hello>
|
||||||
|
<wow>nice</wow>
|
||||||
|
</hello>
|
||||||
|
`;
|
||||||
|
|
||||||
tap.test('should create ', async () => {
|
tap.test('should create an instance', async () => {
|
||||||
testSmartxml = new smartxml.SmartXml();
|
testSmartxml = new smartxml.SmartXml();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -16,5 +21,12 @@ tap.test('should create an xml string', async () => {
|
|||||||
console.log(xmlResult);
|
console.log(xmlResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should parse an yml file', async () => {
|
||||||
|
const jsObject = testSmartxml.parseXmlToObject(testXml);
|
||||||
|
console.log(jsObject);
|
||||||
|
expect(typeof jsObject).to.equal('object');
|
||||||
|
expect(jsObject).property('hello').property('wow').to.equal('nice');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -4,7 +4,7 @@ export class SmartXml {
|
|||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
public parseXmlToObject<T = any>(xmlStringArg: string): T {
|
public parseXmlToObject<T = any>(xmlStringArg: string): T {
|
||||||
const jsonObject = plugins.fastXmlParser.convertToJson(xmlStringArg);
|
const jsonObject = plugins.fastXmlParser.parse(xmlStringArg);
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user