diff --git a/package.json b/package.json index 9aee780..15fc56d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "license": "MIT", "scripts": { "test": "(tstest test/ --web)", - "build": "(tsbuild --web)" + "build": "(tsbuild --web && tsbundle npm)" }, "devDependencies": { "@gitzone/tsbuild": "^2.1.25", diff --git a/test/test.ts b/test/test.ts index ed834b6..bd79f15 100644 --- a/test/test.ts +++ b/test/test.ts @@ -2,8 +2,13 @@ import { expect, tap } from '@pushrocks/tapbundle'; import * as smartxml from '../ts/index'; let testSmartxml: smartxml.SmartXml; +let testXml = ` + + nice + +`; -tap.test('should create ', async () => { +tap.test('should create an instance', async () => { testSmartxml = new smartxml.SmartXml(); }); @@ -16,5 +21,12 @@ tap.test('should create an xml string', async () => { 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(); diff --git a/ts/index.ts b/ts/index.ts index 0311dcf..97b6809 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -4,7 +4,7 @@ export class SmartXml { constructor() {} public parseXmlToObject(xmlStringArg: string): T { - const jsonObject = plugins.fastXmlParser.convertToJson(xmlStringArg); + const jsonObject = plugins.fastXmlParser.parse(xmlStringArg); return jsonObject; }