Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 1779428

Browse files
committed
Added more tests to get up to the 93% threshold for coverage
1 parent b37faab commit 1779428

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

test/fixtures/xmlsanitize2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"e":"<b>Smith</b> & <b>Son</b>"}
1+
{"e":{"$t":"<b>Smith</b> & <b>Son</b>"}}

test/fixtures/xmlsanitize2.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<e>&lt;b&gt;Smith&lt;/b&gt; &amp; &lt;b&gt;Son&lt;/b&gt;</e>
1+
<e>&lt;b&gt;Smith&lt;/b&gt; &amp; &lt;b&gt;Son&lt;/b&gt;</e>

test/test.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,36 @@ describe('xml2json', function () {
9999
it('does xmlsanitize of text', function (done) {
100100

101101
var xml = internals.readFixture('xmlsanitize2.xml');
102-
var result = parser.toJson(xml, {sanitize: true});
102+
var result = parser.toJson(xml, {sanitize: true, reversible: true});
103103
var json = internals.readFixture('xmlsanitize2.json');
104104

105105
expect(result).to.equal(json);
106106

107107
done();
108108
});
109109

110+
it('does json unsanitize', function (done) {
111+
112+
var json = internals.readFixture('xmlsanitize.json');
113+
var result = parser.toXml(json, {sanitize: true});
114+
var xml = internals.readFixture('xmlsanitize.xml');
115+
116+
expect(result).to.equal(xml);
117+
118+
done();
119+
});
120+
121+
it('does json unsanitize of text', function (done) {
122+
123+
var json = internals.readFixture('xmlsanitize2.json');
124+
var result = parser.toXml(json, {sanitize: true});
125+
var xml = internals.readFixture('xmlsanitize2.xml');
126+
127+
expect(result).to.equal(xml);
128+
129+
done();
130+
});
131+
110132
it('throws error on bad options', function (done) {
111133

112134
var throws = function() {

0 commit comments

Comments
 (0)