Skip to content

Commit

Permalink
Added test for #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltwaterC committed Sep 22, 2011
1 parent 08f9a0b commit 0d43b9d
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/attributes.js
@@ -0,0 +1,52 @@
var parser = require('../');

var fs = require('fs');
var assert = require('assert');

var callback = false;
var callbackXPath = false;

var xml = '<thing><real id="width">300</real><real id="height">200</real></thing>';

parser(xml, function (err, res) {
callback = true;
assert.ifError(err);
assert.deepEqual({
"real": [{
"@": {
"id": "width"
},
"#": "300"
}, {
"@": {
"id": "height"
},
"#": "200"
}]
},
res);
});

parser(xml, '//thing/real', function (err, res) {
callbackXPath = true;
assert.ifError(err);
assert.deepEqual([
{
"@": {
"id": "width"
},
"#": "300"
}, {
"@": {
"id": "height"
},
"#": "200"
}
],
res);
});

process.on('exit', function () {
assert.ok(callback);
assert.ok(callbackXPath);
});

0 comments on commit 0d43b9d

Please sign in to comment.