Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Switched to 0.2 defaults, adjusting unittests

  • Loading branch information...
commit df32c2346bbdba268aa500643e484b3fbed71dc3 1 parent 40df209
@Leonidas-from-XIV authored
View
2  lib/xml2js.js
@@ -63,7 +63,7 @@
var key, value, _ref;
this.options = {};
- _ref = exports.defaults["0.1"];
+ _ref = exports.defaults["0.2"];
for (key in _ref) {
if (!__hasProp.call(_ref, key)) continue;
value = _ref[key];
View
2  package.json
@@ -3,7 +3,7 @@
"description" : "Simple XML to JavaScript object converter.",
"keywords" : ["xml", "json"],
"homepage" : "https://github.com/Leonidas-from-XIV/node-xml2js",
- "version" : "0.1.15",
+ "version" : "0.2.0",
"author" : "Marek Kubica <marek@xivilization.net> (http://xivilization.net)",
"contributors" : [
"maqr <maqr.lollerskates@gmail.com> (https://github.com/maqr)",
View
2  src/xml2js.coffee
@@ -44,7 +44,7 @@ class exports.Parser extends events.EventEmitter
constructor: (opts) ->
# copy this versions default options
@options = {}
- @options[key] = value for own key, value of exports.defaults["0.1"]
+ @options[key] = value for own key, value of exports.defaults["0.2"]
# overwrite them with the specified options, if any
@options[key] = value for own key, value of opts
View
28 test/xml2js.test.coffee
@@ -43,20 +43,20 @@ validator = (xpath, currentValue, newValue) ->
module.exports =
'test parse with defaults': skeleton(undefined, (r) ->
console.log 'Result object: ' + util.inspect(r, false, 10)
- assert.equal r['chartest']['@']['desc'], 'Test for CHARs'
- assert.equal r['chartest']['#'], 'Character data here!'
- assert.equal r['cdatatest']['@']['desc'], 'Test for CDATA'
- assert.equal r['cdatatest']['@']['misc'], 'true'
- assert.equal r['cdatatest']['#'], 'CDATA here!'
- assert.equal r['nochartest']['@']['desc'], 'No data'
- assert.equal r['nochartest']['@']['misc'], 'false'
- assert.equal r['listtest']['item'][0]['#'], 'This is character data!'
- assert.equal r['listtest']['item'][0]['subitem'][0], 'Foo(1)'
- assert.equal r['listtest']['item'][0]['subitem'][1], 'Foo(2)'
- assert.equal r['listtest']['item'][0]['subitem'][2], 'Foo(3)'
- assert.equal r['listtest']['item'][0]['subitem'][3], 'Foo(4)'
- assert.equal r['listtest']['item'][1], 'Qux.'
- assert.equal r['listtest']['item'][2], 'Quux.')
+ assert.equal r.sample.chartest[0].$.desc, 'Test for CHARs'
+ assert.equal r.sample.chartest[0]._, 'Character data here!'
+ assert.equal r.sample.cdatatest[0].$.desc, 'Test for CDATA'
+ assert.equal r.sample.cdatatest[0].$.misc, 'true'
+ assert.equal r.sample.cdatatest[0]._, 'CDATA here!'
+ assert.equal r.sample.nochartest[0].$.desc, 'No data'
+ assert.equal r.sample.nochartest[0].$.misc, 'false'
+ assert.equal r.sample.listtest[0].item[0]._, '\n This is\n \n character\n \n data!\n \n '
+ assert.equal r.sample.listtest[0].item[0].subitem[0], 'Foo(1)'
+ assert.equal r.sample.listtest[0].item[0].subitem[1], 'Foo(2)'
+ assert.equal r.sample.listtest[0].item[0].subitem[2], 'Foo(3)'
+ assert.equal r.sample.listtest[0].item[0].subitem[3], 'Foo(4)'
+ assert.equal r.sample.listtest[0].item[1], 'Qux.'
+ assert.equal r.sample.listtest[0].item[2], 'Quux.')
'test parse with explicitCharkey': skeleton(explicitCharkey: true, (r) ->
assert.equal r['chartest']['@']['desc'], 'Test for CHARs'
Please sign in to comment.
Something went wrong with that request. Please try again.