Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some tests, .gitignore, and move some stuff around

  • Loading branch information...
commit 3812df40ca5079063f45bfa591d544858136e97c 1 parent 24ee8b1
Jake Wood authored
View
2  .gitignore
@@ -0,0 +1,2 @@
+node_modules
+.DS_Store
View
1  index.js
@@ -0,0 +1 @@
+module.exports = process.env.XML_COV ? require('./lib-cov/stablexml') : require('./lib/stablexml');
View
0  XMLParser.js → lib/stablexml.js
File renamed without changes
View
48 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: {}
+ }
+ ]
+ }
+ }
+ ]);
+
+ });
+ });
+ });
+
+});
Please sign in to comment.
Something went wrong with that request. Please try again.