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/DocumentConverterTests.java14
1 files changed, 14 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 9287f74..3ae5d16 100644
--- a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
@@ -12,6 +12,9 @@ import java.util.Optional;
import static com.natpryce.makeiteasy.MakeItEasy.*;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.hasProperty;
import static org.zwobble.mammoth.documents.VerticalAlignment.SUBSCRIPT;
import static org.zwobble.mammoth.documents.VerticalAlignment.SUPERSCRIPT;
import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals;
@@ -149,6 +152,17 @@ public class DocumentConverterTests {
deepEquals(list(Html.selfClosingElement("img", map("src", "data:image/png;base64,YWJj")))));
}
+ @Test
+ public void imagesHaveAltTagsIfAvailable() {
+ Image image = new Image(
+ Optional.of("It's a hat"),
+ Optional.of("image/png"),
+ () -> new ByteArrayInputStream(new byte[]{97, 98, 99}));
+ assertThat(
+ convertToHtml(image),
+ contains(hasProperty("attributes", hasEntry("alt", "It's a hat"))));
+ }
+
private List<HtmlNode> convertToHtml(DocumentElement element) {
return documentConverter().convertToHtml(element);
}