summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/MammothTests.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java
index ac81c76..393f1a7 100644
--- a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java
@@ -3,11 +3,16 @@ package org.zwobble.mammoth.tests;
import org.junit.Test;
import org.zwobble.mammoth.DocumentConverter;
import org.zwobble.mammoth.Result;
-import org.zwobble.mammoth.internal.docx.EmbeddedStyleMap;
+import org.zwobble.mammoth.images.ImageConverter;
import org.zwobble.mammoth.internal.archives.InMemoryArchive;
+import org.zwobble.mammoth.internal.docx.EmbeddedStyleMap;
import org.zwobble.mammoth.internal.styles.parsing.ParseException;
+import org.zwobble.mammoth.internal.util.Base64Encoding;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.function.Function;
@@ -15,6 +20,7 @@ import java.util.function.Function;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.zwobble.mammoth.internal.util.Lists.list;
+import static org.zwobble.mammoth.internal.util.Maps.map;
import static org.zwobble.mammoth.tests.ResultMatchers.isResult;
import static org.zwobble.mammoth.tests.ResultMatchers.isSuccess;
import static org.zwobble.mammoth.tests.util.MammothAsserts.assertThrows;
@@ -132,6 +138,19 @@ public class MammothTests {
}
@Test
+ public void imageConversionCanBeCustomised() throws IOException {
+ ImageConverter.ImgElement imageConverter = image -> {
+ String base64 = Base64Encoding.streamToBase64(image::getInputStream);
+ String src = base64.substring(0, 2) + "," + image.getContentType();
+ return map("src", src);
+ };
+ assertThat(
+ convertToHtml("tiny-picture.docx", converter -> converter.imageConverter(imageConverter)),
+ isSuccess("<p><img src=\"iV,image/png\" /></p>")
+ );
+ }
+
+ @Test
public void contentTypesAreRead() throws IOException {
assertThat(
convertToHtml("tiny-picture-custom-content-type.docx"),