Skip to content

Commit

Permalink
update tests for #540
Browse files Browse the repository at this point in the history
  • Loading branch information
amitguptagwl committed Feb 3, 2023
1 parent 62f9e4b commit b6ee2a5
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions spec/unpairedTags_spec.js
Expand Up @@ -8,18 +8,18 @@ describe("unpaired and empty tags", function() {
const xmlData = `<rootNode>
<tag>value</tag>
<empty />
<unpaired>
<unpaired attr="1">
</rootNode>`;
const expectedXmlData = `<rootNode>
<tag>value</tag>
<empty></empty>
<unpaired>
<unpaired attr="1">
</rootNode>`;

const options = {
// format: true,
// preserveOrder: true,
// suppressEmptyNode: true,
ignoreAttributes: false,
unpairedTags: ["unpaired"]
};
const parser = new XMLParser(options);
Expand All @@ -36,13 +36,14 @@ describe("unpaired and empty tags", function() {
const xmlData = `<rootNode>
<tag>value</tag>
<empty />
<unpaired>
<unpaired attr="1">
</rootNode>`;

const options = {
// format: true,
// preserveOrder: true,
suppressEmptyNode: true,
ignoreAttributes: false,
unpairedTags: ["unpaired"]
};
const parser = new XMLParser(options);
Expand All @@ -59,13 +60,14 @@ describe("unpaired and empty tags", function() {
const xmlData = `<rootNode>
<tag>value</tag>
<empty />
<unpaired>
<unpaired attr="1">
</rootNode>`;

const options = {
// format: true,
// preserveOrder: true,
suppressEmptyNode: true,
ignoreAttributes: false,
unpairedTags: ["unpaired"]
};
const parser = new XMLParser(options);
Expand All @@ -80,7 +82,7 @@ describe("unpaired and empty tags", function() {

it("should be parsed when unpaired tag is self-closing or paired closing tag", function() {
const xmlData = `<rootNode>
<unpaired>
<unpaired attr="1">
<self />
<unpaired>
<unpaired />
Expand All @@ -90,7 +92,7 @@ describe("unpaired and empty tags", function() {
</rootNode>`;

const expectedXml = `<rootNode>
<unpaired>
<unpaired attr="1">
<self/>
<unpaired>
<unpaired>
Expand All @@ -102,6 +104,7 @@ describe("unpaired and empty tags", function() {
// format: true,
preserveOrder: true,
suppressEmptyNode: true,
ignoreAttributes: false,
unpairedTags: ["unpaired"]
};
const parser = new XMLParser(options);
Expand All @@ -116,20 +119,21 @@ describe("unpaired and empty tags", function() {

it("should parsed unpaired tag before stop nodes", function() {
const xmlData = `<rootNode>
<unpaired>
<unpaired attr="1">
<stop>here</stop>
<unpaired>
</rootNode>`;

const expectedXml = `<rootNode>
<unpaired>
<unpaired attr="1">
<stop>here</stop>
<unpaired>
</rootNode>`;
const options = {
// format: true,
preserveOrder: true,
suppressEmptyNode: true,
ignoreAttributes: false,
unpairedTags: ["unpaired"],
stopNodes: ["*.stop"]
};
Expand All @@ -147,11 +151,13 @@ describe("unpaired and empty tags", function() {
const xmlData = `<rootNode>
<tag>value</tag>
<empty />
<unpaired attr="1">
<unpaired>
</rootNode>`;
const expectedXmlData = `<rootNode>
<tag>value</tag>
<empty/>
<unpaired attr="1"/>
<unpaired/>
</rootNode>`;

Expand All @@ -160,6 +166,7 @@ describe("unpaired and empty tags", function() {
// preserveOrder: true,
suppressEmptyNode: true,
suppressUnpairedNode: false,
ignoreAttributes: false,
unpairedTags: ["unpaired"]
};
const parser = new XMLParser(options);
Expand All @@ -176,11 +183,13 @@ describe("unpaired and empty tags", function() {
const xmlData = `<rootNode>
<tag>value</tag>
<empty />
<unpaired attr="1">
<unpaired>
</rootNode>`;
const expectedXmlData = `<rootNode>
<tag>value</tag>
<empty></empty>
<unpaired attr="1">
<unpaired>
</rootNode>`;

Expand All @@ -189,6 +198,7 @@ describe("unpaired and empty tags", function() {
// preserveOrder: true,
// suppressEmptyNode: true,
suppressUnpairedNode: true,
ignoreAttributes: false,
unpairedTags: ["unpaired"]
};
const parser = new XMLParser(options);
Expand All @@ -205,11 +215,13 @@ describe("unpaired and empty tags", function() {
const xmlData = `<rootNode>
<tag>value</tag>
<empty />
<unpaired attr="1">
<unpaired>
</rootNode>`;
const expectedXmlData = `<rootNode>
<tag>value</tag>
<empty/>
<unpaired attr="1"/>
<unpaired/>
</rootNode>`;

Expand All @@ -218,6 +230,7 @@ describe("unpaired and empty tags", function() {
preserveOrder: true,
suppressEmptyNode: true,
suppressUnpairedNode: false,
ignoreAttributes: false,
unpairedTags: ["unpaired"]
};
const parser = new XMLParser(options);
Expand All @@ -234,11 +247,13 @@ describe("unpaired and empty tags", function() {
const xmlData = `<rootNode>
<tag>value</tag>
<empty />
<unpaired attr="1">
<unpaired>
</rootNode>`;
const expectedXmlData = `<rootNode>
<tag>value</tag>
<empty></empty>
<unpaired attr="1">
<unpaired>
</rootNode>`;

Expand All @@ -247,6 +262,7 @@ describe("unpaired and empty tags", function() {
preserveOrder: true,
// suppressEmptyNode: true,
suppressUnpairedNode: true,
ignoreAttributes: false,
unpairedTags: ["unpaired"]
};
const parser = new XMLParser(options);
Expand Down

0 comments on commit b6ee2a5

Please sign in to comment.