Add Tests for Fixed Issues

This commit also changes the "fix" for text-only lines. We should be adjusting the text content as little as possible. In this case, we are still adding spaces (or tabs) after the last line break, but that is necessary to indent the closing element. I'll continue to adjust this as needed based on feedback and possibly add a setting to gate this behavior.

#137
This commit is contained in:
Josh Johnson 2018-01-30 17:25:49 -05:00
parent 09fe37f04b
commit 27433b47ce
8 changed files with 34 additions and 15 deletions

View file

@ -28,6 +28,18 @@ describe("V2XmlFormatter", () => {
testFormatter(xmlFormatter, options, "basic");
});
it("should handle unicode element names", () => {
testFormatter(xmlFormatter, options, "unicode");
});
it("should handle self-closing elements", () => {
testFormatter(xmlFormatter, options, "self-closing");
});
it("should handle text-only lines", () => {
testFormatter(xmlFormatter, options, "text-only-line");
});
});
});

View file

@ -0,0 +1,3 @@
<Node>
<Node name="testChild"/>
</Node>

View file

@ -0,0 +1 @@
<Node><Node name="testChild"/></Node>

View file

@ -0,0 +1,6 @@
<Tag>
<Tag2>
Text1
Text2
</Tag2>
</Tag>

View file

@ -0,0 +1,6 @@
<Tag>
<Tag2>
Text1
Text2
</Tag2>
</Tag>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<Имя>
<element>text</element>
</Имя>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Имя><element>text</element></Имя>