aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-02-21 10:09:47 +0000
committerMichael Williamson <mike@zwobble.org>2016-02-21 10:09:47 +0000
commit8377b89bfc97a85dbe90fb4cfa5dd33cd3568af4 (patch)
treec37ec926bfb9cf2c45ebfb564edb596fa1e0965a /src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
parentc1604e510cc831a00f6105df35c68a856f061b65 (diff)
Add style mappings for runs
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java28
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")))))),