summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-02-14 11:42:26 +0000
committerMichael Williamson <mike@zwobble.org>2016-02-14 11:42:26 +0000
commit8bdef5495085e7258ca884bdcc0159c264181895 (patch)
treeac95ac3dafd6c747be7cbde8ca5788fa9844b2cd /src/test/java
parent2c4946f27b559245d070a6d85ccfbea3d3051134 (diff)
Convert hyperlinks with href to HTML
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
index ff12f5d..db3087e 100644
--- a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
@@ -4,6 +4,7 @@ import org.junit.Test;
import org.zwobble.mammoth.DocumentConverter;
import org.zwobble.mammoth.documents.Document;
import org.zwobble.mammoth.documents.DocumentElement;
+import org.zwobble.mammoth.documents.Hyperlink;
import org.zwobble.mammoth.documents.Text;
import org.zwobble.mammoth.html.Html;
import org.zwobble.mammoth.html.HtmlNode;
@@ -17,6 +18,7 @@ import static org.zwobble.mammoth.documents.VerticalAlignment.SUPERSCRIPT;
import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals;
import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.*;
import static org.zwobble.mammoth.util.MammothLists.list;
+import static org.zwobble.mammoth.util.MammothMaps.map;
public class DocumentConverterTests {
// TODO: styles (paragraph, run, underline, strikethrough)
@@ -82,6 +84,13 @@ public class DocumentConverterTests {
deepEquals(list(Html.element("sub", list(Html.text("Hello"))))));
}
+ @Test
+ public void hyperlinkWithHrefIsConvertedToAnchorTag() {
+ assertThat(
+ convertToHtml(Hyperlink.href("http://example.com", list(new Text("Hello")))),
+ deepEquals(list(Html.element("a", map("href", "http://example.com"), list(Html.text("Hello"))))));
+ }
+
private List<HtmlNode> convertToHtml(DocumentElement element) {
return DocumentConverter.convertToHtml(element);