aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-02-24 09:04:14 +0000
committerMichael Williamson <mike@zwobble.org>2016-02-24 09:04:14 +0000
commit8dd12c1ca7703a085b57fe4c5c35ef6e19d92134 (patch)
tree2e2c47733e868a6a0deadceed8b1c564643bb2cc /src/test/java/org/zwobble
parent9903fc49d41142934012a5ec2bf16d80f0cf4b16 (diff)
Allow style maps to be added
Diffstat (limited to 'src/test/java/org/zwobble')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java2
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/MammothTests.java21
2 files changed, 22 insertions, 1 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
index 4c40800..df60d06 100644
--- a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
@@ -312,7 +312,7 @@ public class DocumentConverterTests {
private Result<List<HtmlNode>> convertToHtmlResult(DocumentElement element, StyleMap styleMap) {
DocumentToHtmlOptions options = DocumentToHtmlOptions.DEFAULT
.idPrefix("doc-42-")
- .styleMap(styleMap);
+ .addStyleMap(styleMap);
return DocumentConverter.convertToHtml(element, options);
}
}
diff --git a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java
index 6e5794a..288c6a2 100644
--- a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java
@@ -168,6 +168,27 @@ public class MammothTests {
}
@Test
+ public void canUseCustomStyleMap() throws IOException {
+ assertThat(
+ convertToHtml("underline.docx", mammoth -> mammoth.addStyleMap("u => em")),
+ deepEquals(success("<p><strong>The <em>Sunset</em> Tree</strong></p>")));
+ }
+
+ @Test
+ public void mostRecentlyAddedStyleMapTakesPrecedence() throws IOException {
+ assertThat(
+ convertToHtml("underline.docx", mammoth -> mammoth.addStyleMap("u => em").addStyleMap("u => strong")),
+ deepEquals(success("<p><strong>The <strong>Sunset</strong> Tree</strong></p>")));
+ }
+
+ @Test
+ public void rulesFromPreviouslyAddedStyleMapsStillTakeEffectIfNotOverriden() throws IOException {
+ assertThat(
+ convertToHtml("underline.docx", mammoth -> mammoth.addStyleMap("u => em").addStyleMap("s => del")),
+ deepEquals(success("<p><strong>The <em>Sunset</em> Tree</strong></p>")));
+ }
+
+ @Test
public void canExtractRawText() throws IOException {
assertThat(
Mammoth.extractRawText(TestData.file("simple-list.docx")),