Add tests to check that empty input renders to empty output Change-Id: I1f6d8168f4c6bfd5000a6f3f2d33a02d3d07e0b3
diff --git a/src/test/java/com/googlesource/gerrit/plugins/x-docs/AsciidoctorFormatterTest.java b/src/test/java/com/googlesource/gerrit/plugins/x-docs/AsciidoctorFormatterTest.java index 648e42c..f4b5084 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/x-docs/AsciidoctorFormatterTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/x-docs/AsciidoctorFormatterTest.java
@@ -65,6 +65,11 @@ } @Test + public void emptyInputRendersNothing() throws IOException { + assertEquals(StringUtils.EMPTY, formatter.format(null, null, null, null, cfg, StringUtils.EMPTY)); + } + + @Test public void basicTextFormattingWorks() throws IOException { String raw = "_italic_ *bold* `monospace`"; String formatted = "<em>italic</em> <strong>bold</strong> <code>monospace</code>";
diff --git a/src/test/java/com/googlesource/gerrit/plugins/x-docs/MarkdownFormatterTest.java b/src/test/java/com/googlesource/gerrit/plugins/x-docs/MarkdownFormatterTest.java index 0ddb58d..8294f30 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/x-docs/MarkdownFormatterTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/x-docs/MarkdownFormatterTest.java
@@ -21,13 +21,14 @@ import java.io.IOException; +import org.apache.commons.lang.StringUtils; import org.junit.Before; import org.junit.Test; public class MarkdownFormatterTest { - private static final String PROLOG = "<html><head><style type=\"text/css\">\n\n</style></head><body>\n<p>"; - private static final String EPILOG = "</p>\n</body></html>"; + private static final String PROLOG = "<html><head><style type=\"text/css\">\n\n</style></head><body>\n"; + private static final String EPILOG = "\n</body></html>"; private ConfigSection cfg; private MarkdownFormatter formatter; @@ -57,9 +58,14 @@ } @Test + public void emptyInputRendersNothing() throws IOException { + assertEquals(PROLOG + EPILOG, formatter.format(null, null, null, null, cfg, StringUtils.EMPTY)); + } + + @Test public void basicTextFormattingWorks() throws IOException { String raw = "*italic* **bold** `monospace`"; - String formatted = PROLOG + "<em>italic</em> <strong>bold</strong> <code>monospace</code>" + EPILOG; + String formatted = PROLOG + "<p><em>italic</em> <strong>bold</strong> <code>monospace</code></p>" + EPILOG; assertEquals(formatted, formatter.format(null, null, null, null, cfg, raw)); } }