Comparing version 0.0.4-a to 0.0.5
@@ -101,3 +101,3 @@ var toXML = function(obj, addHeader, indent){ | ||
indent: indent, | ||
attrs: input.attrs | ||
attrs: input._attrs | ||
} | ||
@@ -104,0 +104,0 @@ |
{ | ||
"name": "jstoxml", | ||
"version": "0.0.4a", | ||
"version": "0.0.5", | ||
"description": "Everyone loves JSON, and the world is moving that direction, but we still need things outputted in XML! Particularly for RSS and Podcast feeds. jstoxml makes it easy to contruct those feeds in JavaScript and output them to XML", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/davidcalhoun/jstoxml", |
164
test.js
@@ -1,2 +0,2 @@ | ||
var jstoxml = require('jstoxml'); | ||
var jstoxml = require('./jstoxml.js'); | ||
@@ -25,4 +25,6 @@ (function(){ | ||
results.testsRun++; | ||
if(output !== test.expectedOutput){ | ||
console.log(output + '\n !== \n' + test.expectedOutput); | ||
console.log(output + '\n!==\n\n' + test.expectedOutput); | ||
console.log(test.name + ' failed. ' + results.testsRun + '/' + tests.length); | ||
@@ -47,5 +49,45 @@ results.fail++; | ||
addTest({ | ||
name: 'basic1', | ||
name: 'string', | ||
input: function(){ | ||
jstoxml.toXML({ | ||
return jstoxml.toXML('foo') | ||
}, | ||
expectedOutput: 'foo\n' | ||
}); | ||
addTest({ | ||
name: 'function', | ||
input: function(){ | ||
return jstoxml.toXML(function(){ | ||
return 999; | ||
}) | ||
}, | ||
expectedOutput: '999\n' | ||
}); | ||
addTest({ | ||
name: 'array', | ||
input: function(){ | ||
return jstoxml.toXML([ | ||
{foo: 'bar'}, | ||
{foo2: 'bar2'} | ||
]) | ||
}, | ||
expectedOutput: '<foo>bar</foo>\n<foo2>bar2</foo2>\n' | ||
}); | ||
addTest({ | ||
name: 'array-advanced', | ||
input: function(){ | ||
return jstoxml.toXML([ | ||
{foo: 'bar'}, | ||
{foo2: 'bar2'} | ||
]) | ||
}, | ||
expectedOutput: '<foo>bar</foo>\n<foo2>bar2</foo2>\n' | ||
}); | ||
addTest({ | ||
name: 'object', | ||
input: function(){ | ||
return jstoxml.toXML({ | ||
foo: 'bar', | ||
@@ -58,2 +100,116 @@ foo2: 'bar2' | ||
addTest({ | ||
name: 'object-xml-header', | ||
input: function(){ | ||
return jstoxml.toXML({ | ||
foo: 'bar', | ||
foo2: 'bar2' | ||
}, true) | ||
}, | ||
expectedOutput: '<?xml version="1.0" encoding="UTF-8"?>\n<foo>bar</foo>\n<foo2>bar2</foo2>\n' | ||
}); | ||
addTest({ | ||
name: 'object-with-tabs', | ||
input: function(){ | ||
return jstoxml.toXML({ | ||
a: { | ||
foo: 'bar', | ||
foo2: 'bar2' | ||
} | ||
}, false, ' ') | ||
}, | ||
expectedOutput: '<a>\n <foo>bar</foo>\n <foo2>bar2</foo2>\n</a>\n' | ||
}); | ||
addTest({ | ||
name: 'object-with-attributes', | ||
input: function(){ | ||
return jstoxml.toXML({ | ||
_name: 'a', | ||
_attrs: { | ||
foo: 'bar', | ||
foo2: 'bar2' | ||
} | ||
}) | ||
}, | ||
expectedOutput: '<a foo="bar" foo2="bar2"/>\n' | ||
}); | ||
addTest({ | ||
name: 'object-with-attributes2', | ||
input: function(){ | ||
return jstoxml.toXML({ | ||
_name: 'a', | ||
_attrs: { | ||
foo: 'bar', | ||
foo2: 'bar2' | ||
}, | ||
_content: 'la dee da' | ||
}) | ||
}, | ||
expectedOutput: '<a foo="bar" foo2="bar2">la dee da</a>\n' | ||
}); | ||
addTest({ | ||
name: 'object-mixed', | ||
input: function(){ | ||
return jstoxml.toXML({ | ||
'blah': '', | ||
foo: 'bar', | ||
'more blah': '' | ||
}) | ||
}, | ||
expectedOutput: 'blah\n<foo>bar</foo>\nmore blah\n' | ||
}); | ||
addTest({ | ||
name: 'object-nested', | ||
input: function(){ | ||
return jstoxml.toXML({ | ||
a: { | ||
foo: 'bar', | ||
foo2: 'bar2' | ||
} | ||
}) | ||
}, | ||
expectedOutput: '<a>\n<foo>bar</foo>\n<foo2>bar2</foo2>\n</a>\n' | ||
}); | ||
addTest({ | ||
name: 'object-deep-nesting', | ||
input: function(){ | ||
return jstoxml.toXML({ | ||
a: { | ||
b: { | ||
c: { | ||
d: { | ||
e: { | ||
f: { | ||
g: { | ||
h: { | ||
i: { | ||
j: { | ||
k: { | ||
l: { | ||
m: { | ||
foo: 'bar' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
}, | ||
expectedOutput: '<a>\n<b>\n<c>\n<d>\n<e>\n<f>\n<g>\n<h>\n<i>\n<j>\n<k>\n<l>\n<m>\n<foo>bar</foo>\n</m>\n</l>\n</k>\n</j>\n</i>\n</h>\n</g>\n</f>\n</e>\n</d>\n</c>\n</b>\n</a>\n' | ||
}); | ||
runTests(); | ||
@@ -60,0 +216,0 @@ showReport(); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
10240
4
306