You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/j2x_spec.js
+36Lines changed: 36 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -235,6 +235,42 @@ describe("XMLParser", function () {
235
235
expect(result).toEqual(expected);
236
236
});
237
237
238
+
it("should supress empty node to self closing node when parsing to XML",function(){
239
+
varjObj={
240
+
a : {
241
+
"@": {
242
+
b : "val>1",
243
+
c : "val<2"
244
+
},
245
+
"#text": "text\\cvalue>\\c",
246
+
tag: {
247
+
k: 34,
248
+
g: "",
249
+
nested: {
250
+
"@": {
251
+
b : "val>1",
252
+
c : "val<2"
253
+
}
254
+
}
255
+
},
256
+
"__cdata": [
257
+
"this text is > from CDATA",
258
+
""
259
+
]
260
+
}
261
+
};
262
+
varparser=newParser({
263
+
cdataTagName : "__cdata",
264
+
attrNodeName : "@",
265
+
encodeHTMLchar: true,
266
+
supressEmptyNode: true
267
+
});
268
+
varresult=parser.parse(jObj);
269
+
//console.log(result);
270
+
varexpected='<a b="val>1" c="val<2"><tag><k>34</k><g/><nested b="val>1" c="val<2"/></tag>text<![CDATA[this text is > from CDATA]]>value><![CDATA[]]></a>';
271
+
expect(result).toEqual(expected);
272
+
});
273
+
238
274
239
275
/* it("should format when parsing to XML", function () {
0 commit comments