Add Failing Test

This commit is contained in:
Josh Johnson 2020-07-01 23:12:48 -04:00
parent 4337ba21ae
commit f156845afb
3 changed files with 60 additions and 0 deletions

View File

@ -101,6 +101,26 @@ describe("V2XmlFormatter", () => {
});
});
describe("#minifyXml(xml, options)", () => {
const options = {
editorOptions: {
insertSpaces: true,
tabSize: 4
},
enforcePrettySelfClosingTagOnFormat: false,
newLine: "\r\n",
removeCommentsOnMinify: false,
splitAttributesOnFormat: false,
splitXmlnsOnFormat: true
};
it("should preserve whitespace on minify if xml:space is set to 'preserve-whitespace'", () => {
testMinifier(xmlFormatter, options, "issue-262");
});
});
});
function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void {
@ -111,3 +131,12 @@ function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions
assert.equal(actualFormattedXml, expectedFormattedXml, "Actual formatted XML does not match expected formatted XML.");
}
function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void {
const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`);
const unminifiedXml = TestDataLoader.load(`${fileLabel}.unminified.xml`);
const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options);
assert.equal(actualMinifiedXml, expectedMinifiedXml, "Actual minified XML does not match expected minified XML.");
}

View File

@ -0,0 +1,13 @@
<tests><test>1.
2.
3.
4.</test><test xml:space="preserve">1.
2.
3.
4.</test><test>1.
2.
3.
4.</test><test xml:space="preserve">1.
2.
3.
4.</test></tests>

View File

@ -0,0 +1,18 @@
<tests>
<test>1.
2.
3.
4.</test>
<test xml:space="preserve">1.
2.
3.
4.</test>
<test>1.
2.
3.
4.</test>
<test xml:space="preserve">1.
2.
3.
4.</test>
</tests>