diff options
Diffstat (limited to 'src/test/java/org')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java | 2 | ||||
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/MammothTests.java | 21 |
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")), |
