Skip to content

Commit

Permalink
Add some tests, .gitignore, and move some stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Wood committed Feb 11, 2013
1 parent 24ee8b1 commit 3812df4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
node_modules
.DS_Store
1 change: 1 addition & 0 deletions index.js
@@ -0,0 +1 @@
module.exports = process.env.XML_COV ? require('./lib-cov/stablexml') : require('./lib/stablexml');
File renamed without changes.
48 changes: 48 additions & 0 deletions test/index.js
@@ -0,0 +1,48 @@
var assert = require("assert");
suite('StableXML', function() {

var XMLParser = require("../index");
var parser;

setup(function() {
parser = new XMLParser();
});

suite("#parseXML()", function() {
test("should produce <test />", function() {
parser.parseXML("<test />", function(err, results) {
assert.deepEqual(results, [{ test:{} }]);
});
});
test('should produce <test foo="bar" />', function() {
parser.parseXML('<test foo="bar" />', function(err, results) {
assert.deepEqual(results, [
{
test: {
$: {
foo: "bar"
}
}
}
]);
});
});
test('should produce <test><foo /></test>', function() {
parser.parseXML('<test><foo /></test>', function(err, results) {
assert.deepEqual(results, [
{
test: {
_: [
{
foo: {}
}
]
}
}
]);

});
});
});

});

0 comments on commit 3812df4

Please sign in to comment.