Permalink
Browse files

Added test for #6.

  • Loading branch information...
1 parent 08f9a0b commit 0d43b9d740d193891709d4a2603fa8dbda2572e0 @SaltwaterC committed Sep 22, 2011
Showing with 52 additions and 0 deletions.
  1. +52 −0 tests/attributes.js
View
@@ -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.