diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-02-14 12:58:58 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-02-14 12:58:58 +0000 |
| commit | a82d898bc1c6901749f89a905e63c9e511baae84 (patch) | |
| tree | 12d5c2d6557c718fda59c43226ea97c39e72ba74 /src/test/java/org/zwobble | |
| parent | 3eb73c4ba53dc273e9724d1b4a498502628eaf8f (diff) | |
Include alt text for images if available
Diffstat (limited to 'src/test/java/org/zwobble')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java | 14 |
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); } |
