diff options
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java | 28 |
1 files changed, 28 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 bc37ad9..95fbe5d 100644 --- a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java @@ -8,6 +8,7 @@ import org.zwobble.mammoth.html.HtmlNode; import org.zwobble.mammoth.results.Result; import org.zwobble.mammoth.styles.HtmlPath; import org.zwobble.mammoth.styles.ParagraphMatcher; +import org.zwobble.mammoth.styles.RunMatcher; import org.zwobble.mammoth.styles.StyleMap; import java.io.ByteArrayInputStream; @@ -81,6 +82,33 @@ public class DocumentConverterTests { } @Test + public void runStyleMappingsCanBeUsedToMapRuns() { + assertThat( + convertToHtml( + make(a(RUN, with(STYLE, Optional.of(new Style("TipsRun", Optional.empty()))))), + StyleMap.builder() + .mapRun( + RunMatcher.styleId("TipsRun"), + HtmlPath.element("span", map("class", "tip"))) + .build()), + + deepEquals(list(Html.element("span", map("class", "tip"))))); + } + + @Test + public void warningIfRunHasUnrecognisedStyle() { + assertThat( + convertToHtmlResult( + make(a(RUN, + with(STYLE, Optional.of(new Style("TipsRun", Optional.of("Tips Run")))), + with(CHILDREN, list(new Text("Hello")))))), + + deepEquals(new Result<>( + list(Html.text("Hello")), + list(warning("Unrecognised run style: Tips Run (Style ID: TipsRun)"))))); + } + + @Test public void boldRunsAreWrappedInStrongTags() { assertThat( convertToHtml(make(a(RUN, with(BOLD, true), with(CHILDREN, list(new Text("Hello")))))), |
