diff options
Diffstat (limited to 'src/test/java/org/zwobble/mammoth')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/MammothTests.java | 9 | ||||
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/docx/Uris.java | 25 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java index d7a2b66..ac81c76 100644 --- a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java @@ -69,13 +69,20 @@ public class MammothTests { } @Test - public void inlineImagesAreIncludedInOutput() throws IOException { + public void inlineImagesReferencedByPathRelativeToPartAreIncludedInOutput() throws IOException { assertThat( convertToHtml("tiny-picture.docx"), isSuccess("<p><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=\" /></p>")); } @Test + public void inlineImagesReferencedByPathRelativeToBaseAreIncludedInOutput() throws IOException { + assertThat( + convertToHtml("tiny-picture-target-base-relative.docx"), + isSuccess("<p><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=\" /></p>")); + } + + @Test public void imagesStoredOutsideOfDocumentAreIncludedInOutput() throws IOException { Path tempDirectory = Files.createTempDirectory("mammoth-"); try { diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/Uris.java b/src/test/java/org/zwobble/mammoth/tests/docx/Uris.java new file mode 100644 index 0000000..36d4bcb --- /dev/null +++ b/src/test/java/org/zwobble/mammoth/tests/docx/Uris.java @@ -0,0 +1,25 @@ +package org.zwobble.mammoth.tests.docx; + +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.zwobble.mammoth.internal.docx.Uris.uriToZipEntryName; + +public class Uris { + @Test + public void whenPathDoesNotHaveLeadingSlashThenPathIsResolvedRelativeToBase() { + assertThat( + uriToZipEntryName("one/two", "three/four"), + equalTo("one/two/three/four") + ); + } + + @Test + public void whenPathHasLeadingSlashThenBaseIsIgnored() { + assertThat( + uriToZipEntryName("one/two", "/three/four"), + equalTo("three/four") + ); + } +} |
