summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-09-02 21:23:50 +0100
committerMichael Williamson <mike@zwobble.org>2016-09-02 21:23:50 +0100
commit91ddc155e5c1da5e7e948569b6f367d2427ba32a (patch)
treec17fe3df96718f2359b601be41e69efb3b217169
parente41a32eab2d747608d6c77cbc00a4992ef71d29a (diff)
Extract imageBuffer value
-rw-r--r--test/docx/body-reader.tests.js25
1 files changed, 11 insertions, 14 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js
index 024a667..b610254 100644
--- a/test/docx/body-reader.tests.js
+++ b/test/docx/body-reader.tests.js
@@ -394,17 +394,18 @@ test('_GoBack bookmark is ignored', function() {
assert.deepEqual(result.value, []);
});
+var IMAGE_BUFFER = new Buffer("Not an image at all!");
+
test("can read imagedata elements with r:id attribute", function() {
var imagedataElement = new XmlElement("v:imagedata", {"r:id": "rId5", "o:title": "It's a hat"});
- var imageBuffer = new Buffer("Not an image at all!");
var element = readXmlElementValue(imagedataElement, {
relationships: {
"rId5": {target: "media/hat.png"}
},
contentTypes: fakeContentTypes,
docxFile: createFakeDocxFile({
- "word/media/hat.png": imageBuffer
+ "word/media/hat.png": IMAGE_BUFFER
})
});
assert.equal("image", element.type);
@@ -412,7 +413,7 @@ test("can read imagedata elements with r:id attribute", function() {
assert.equal(element.contentType, "image/png");
return element.read()
.then(function(readValue) {
- assert.equal(readValue, imageBuffer);
+ assert.equal(readValue, IMAGE_BUFFER);
});
});
@@ -422,14 +423,13 @@ test("can read inline pictures", function() {
description: "It's a hat"
});
- var imageBuffer = new Buffer("Not an image at all!");
var element = single(readXmlElementValue(drawing, {
relationships: {
"rId5": {target: "media/hat.png"}
},
contentTypes: fakeContentTypes,
docxFile: createFakeDocxFile({
- "word/media/hat.png": imageBuffer
+ "word/media/hat.png": IMAGE_BUFFER
})
}));
assert.equal("image", element.type);
@@ -437,7 +437,7 @@ test("can read inline pictures", function() {
assert.equal(element.contentType, "image/png");
return element.read()
.then(function(readValue) {
- assert.equal(readValue, imageBuffer);
+ assert.equal(readValue, IMAGE_BUFFER);
});
});
@@ -457,21 +457,20 @@ test("can read anchored pictures", function() {
])
]);
- var imageBuffer = new Buffer("Not an image at all!");
var element = single(readXmlElementValue(drawing, {
relationships: {
"rId5": {target: "media/hat.png"}
},
contentTypes: fakeContentTypes,
docxFile: createFakeDocxFile({
- "word/media/hat.png": imageBuffer
+ "word/media/hat.png": IMAGE_BUFFER
})
}));
assert.equal("image", element.type);
assert.equal(element.altText, "It's a hat");
return element.read()
.then(function(readValue) {
- assert.equal(readValue, imageBuffer);
+ assert.equal(readValue, IMAGE_BUFFER);
});
});
@@ -481,14 +480,13 @@ test("can read linked pictures", function() {
description: "It's a hat"
});
- var imageBuffer = new Buffer("Not an image at all!");
var element = single(readXmlElementValue(drawing, {
relationships: {
"rId5": {target: "file:///media/hat.png"}
},
contentTypes: fakeContentTypes,
files: testing.createFakeFiles({
- "file:///media/hat.png": imageBuffer
+ "file:///media/hat.png": IMAGE_BUFFER
})
}));
assert.equal("image", element.type);
@@ -496,7 +494,7 @@ test("can read linked pictures", function() {
assert.equal(element.contentType, "image/png");
return element.read()
.then(function(readValue) {
- assert.equal(readValue, imageBuffer);
+ assert.equal(readValue, IMAGE_BUFFER);
});
});
@@ -506,14 +504,13 @@ test("warning if unsupported image type", function() {
description: "It's a hat"
});
- var imageBuffer = new Buffer("Not an image at all!");
var result = readXmlElement(drawing, {
relationships: {
"rId5": {target: "media/hat.emf"}
},
contentTypes: fakeContentTypes,
docxFile: createFakeDocxFile({
- "word/media/hat.emf": imageBuffer
+ "word/media/hat.emf": IMAGE_BUFFER
})
});
assert.deepEqual(result.messages, [warning("Image of type image/x-emf is unlikely to display in web browsers")]);