From bba2f4d95240ea3569e253609e95cc94c5c8ef13 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 20 Feb 2016 14:20:40 +0000 Subject: Add strikethrough to style map --- .../zwobble/mammoth/tests/DocumentConverterTests.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/test/java/org/zwobble') diff --git a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java index fd1402f..f81962b 100644 --- a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java @@ -6,7 +6,6 @@ import org.zwobble.mammoth.documents.*; import org.zwobble.mammoth.html.Html; import org.zwobble.mammoth.html.HtmlNode; import org.zwobble.mammoth.styles.HtmlPath; -import org.zwobble.mammoth.styles.HtmlPathElement; import org.zwobble.mammoth.styles.StyleMap; import java.io.ByteArrayInputStream; @@ -15,9 +14,7 @@ import java.util.Optional; import static com.natpryce.makeiteasy.MakeItEasy.*; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.hasEntry; -import static org.hamcrest.Matchers.hasProperty; +import static org.hamcrest.Matchers.*; import static org.zwobble.mammoth.documents.VerticalAlignment.SUBSCRIPT; import static org.zwobble.mammoth.documents.VerticalAlignment.SUPERSCRIPT; import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; @@ -80,7 +77,8 @@ public class DocumentConverterTests { assertThat( convertToHtml( make(a(RUN, with(UNDERLINE, true), with(CHILDREN, list(new Text("Hello"))))), - new StyleMap(new HtmlPath(list(new HtmlPathElement("em"))))), + StyleMap.builder().underline(HtmlPath.element("em")).build()), + deepEquals(list(Html.element("em", list(Html.text("Hello")))))); } @@ -91,6 +89,15 @@ public class DocumentConverterTests { deepEquals(list(Html.collapsibleElement("s", list(Html.text("Hello")))))); } + @Test + public void struckthroughRunsCanBeMappedUsingStyleMapping() { + assertThat( + convertToHtml( + make(a(RUN, with(STRIKETHROUGH, true), with(CHILDREN, list(new Text("Hello"))))), + StyleMap.builder().strikethrough(HtmlPath.element("del")).build()), + deepEquals(list(Html.element("del", list(Html.text("Hello")))))); + } + @Test public void superscriptRunsAreWrappedInSuperscriptTags() { assertThat( -- cgit v1.2.3