Add Failing Test

This commit is contained in:
Josh Johnson 2020-07-06 22:58:46 -04:00
parent 6689fd34a7
commit 6fd54a2d01
3 changed files with 18 additions and 2 deletions

View File

@ -99,6 +99,10 @@ describe("V2XmlFormatter", () => {
it("should handle mixed content as a child of another element", () => { it("should handle mixed content as a child of another element", () => {
testFormatter(xmlFormatter, options, "issue-257"); testFormatter(xmlFormatter, options, "issue-257");
}); });
it("should not touch CDATA content", () => {
testFormatter(xmlFormatter, options, "issue-293");
});
}); });
describe("#minifyXml(xml, options)", () => { describe("#minifyXml(xml, options)", () => {
@ -130,7 +134,7 @@ function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions
const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/g, ""); const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/g, "");
// tslint:disable-next-line // tslint:disable-next-line
assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml.replace(/\s/, "~ws~")}\n\nEXPECTED\n${expectedFormattedXml.replace(/\s/, "~ws~")}`); assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml.replace(/\s/g, "~ws~")}\n\nEXPECTED\n${expectedFormattedXml.replace(/\s/g, "~ws~")}`);
} }
function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void {
@ -140,5 +144,5 @@ function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions,
const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/g, ""); const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/g, "");
// tslint:disable-next-line // tslint:disable-next-line
assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml.replace(/\s/, "~ws~")}\n\nEXPECTED\n${expectedMinifiedXml.replace(/\s/, "~ws~")}`); assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml.replace(/\s/g, "~ws~")}\n\nEXPECTED\n${expectedMinifiedXml.replace(/\s/g, "~ws~")}`);
} }

View File

@ -0,0 +1,6 @@
<xml>
<element><![CDATA[asdf]]></element>
<element><![CDATA[<secondXml>
<formattedNode>val</formattedNode>
</secondXml>]]></element>
</xml>

View File

@ -0,0 +1,6 @@
<xml>
<element><![CDATA[asdf]]></element>
<element><![CDATA[<secondXml>
<formattedNode>val</formattedNode>
</secondXml>]]></element>
</xml>