@@ -99,14 +99,57 @@ 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+
132+ it ( 'does doesnt double sanitize' , function ( done ) {
133+
134+ var json = internals . readFixture ( 'xmlsanitize3.json' ) ;
135+ var result = parser . toXml ( json , { sanitize : true } ) ;
136+ var xml = internals . readFixture ( 'xmlsanitize3.xml' ) ;
137+
138+ expect ( result ) . to . equal ( xml ) ;
139+
140+ done ( ) ;
141+ } ) ;
142+
143+ it ( 'does doesnt double unsanitize' , function ( done ) {
144+
145+ var xml = internals . readFixture ( 'xmlsanitize3.xml' ) ;
146+ var result = parser . toJson ( xml , { sanitize : true , reversible : true } ) ;
147+ var json = internals . readFixture ( 'xmlsanitize3.json' ) ;
148+
149+ expect ( result ) . to . equal ( json ) ;
150+ done ( ) ;
151+ } ) ;
152+
110153 it ( 'converts with forceArrays' , function ( done ) {
111154 var xml = internals . readFixture ( 'forceArray.xml' ) ;
112155 var result = parser . toJson ( xml , { arrayNotation : [ 'drivers' , 'vehicles' ] } ) ;
@@ -247,8 +290,8 @@ describe('json2xml', function () {
247290
248291 it ( 'works with array notation' , function ( done ) {
249292
250- var xml = fs . readFileSync ( './test/fixtures/ array-notation.xml') ;
251- var expectedJson = JSON . parse ( fs . readFileSync ( './test/fixtures/ array-notation.json') ) ;
293+ var xml = internals . readFixture ( ' array-notation.xml') ;
294+ var expectedJson = JSON . parse ( internals . readFixture ( ' array-notation.json') ) ;
252295
253296 var json = parser . toJson ( xml , { object : true , arrayNotation : true } ) ;
254297
0 commit comments