aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-09-02 22:06:01 +0100
committerMichael Williamson <mike@zwobble.org>2016-09-02 22:06:01 +0100
commitf6c25f725de0c4ee65e4a0d25aa1c08774b2b809 (patch)
tree2bdeb7d65616d5ab798d1f25079818def4f9eec8 /test
parente5953b770484277e9119cef8358434cfad09df6b (diff)
Use alt text title if description is blank
Diffstat (limited to 'test')
-rw-r--r--test/docx/body-reader.tests.js34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js
index 45b04ea..de9a6f9 100644
--- a/test/docx/body-reader.tests.js
+++ b/test/docx/body-reader.tests.js
@@ -464,6 +464,38 @@ test("can read inline pictures", function() {
}))));
});
+test("alt text title is used if alt text description is blank", function() {
+ var drawing = createInlineImage({
+ blip: createEmbeddedBlip(IMAGE_RELATIONSHIP_ID),
+ description: " ",
+ title: "It's a hat"
+ });
+
+ var result = readEmbeddedImage(drawing);
+
+ return promiseThat(result, isSuccess(contains(isImage({
+ altText: "It's a hat",
+ contentType: "image/png",
+ buffer: IMAGE_BUFFER
+ }))));
+});
+
+test("alt text description is preferred to alt text title", function() {
+ var drawing = createInlineImage({
+ blip: createEmbeddedBlip(IMAGE_RELATIONSHIP_ID),
+ description: "It's a hat",
+ title: "hat"
+ });
+
+ var result = readEmbeddedImage(drawing);
+
+ return promiseThat(result, isSuccess(contains(isImage({
+ altText: "It's a hat",
+ contentType: "image/png",
+ buffer: IMAGE_BUFFER
+ }))));
+});
+
test("can read anchored pictures", function() {
var drawing = new XmlElement("w:drawing", {}, [
new XmlElement("wp:anchor", {}, [
@@ -715,7 +747,7 @@ function single(array) {
function createInlineImage(options) {
return new XmlElement("w:drawing", {}, [
new XmlElement("wp:inline", {}, [
- new XmlElement("wp:docPr", {descr: options.description}),
+ new XmlElement("wp:docPr", {descr: options.description, title: options.title}),
new XmlElement("a:graphic", {}, [
new XmlElement("a:graphicData", {}, [
new XmlElement("pic:pic", {}, [