summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-05-28 19:05:05 +0100
committerMichael Williamson <mike@zwobble.org>2023-05-28 19:05:05 +0100
commit82f8d243b6aba94bd9ed083f242f2470e00fc122 (patch)
tree1c673dc2ac16e293e3e659f1da35343f012d4469 /test
parentb2b2c35715985f624e6b696fd87140fa6056318f (diff)
Support readAsBuffer() on images
Diffstat (limited to 'test')
-rw-r--r--test/mammoth.tests.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/mammoth.tests.js b/test/mammoth.tests.js
index bbbbe37..9f0e902 100644
--- a/test/mammoth.tests.js
+++ b/test/mammoth.tests.js
@@ -275,6 +275,21 @@ test('src of inline images can be changed using read()', function() {
});
});
+test('src of inline images can be changed using readAsBuffer()', function() {
+ var docxPath = path.join(__dirname, "test-data/tiny-picture.docx");
+ var convertImage = mammoth.images.imgElement(function(element) {
+ return element.readAsBuffer().then(function(buffer) {
+ assert.ok(Buffer.isBuffer(buffer));
+ var encodedImage = buffer.toString("base64");
+ return {src: encodedImage.substring(0, 2) + "," + element.contentType};
+ });
+ });
+ return mammoth.convertToHtml({path: docxPath}, {convertImage: convertImage}).then(function(result) {
+ assert.deepEqual(result.messages, []);
+ assert.equal(result.value, '<p><img src="iV,image/png" /></p>');
+ });
+});
+
test('images stored outside of document are included in output', function() {
var docxPath = path.join(__dirname, "test-data/external-picture.docx");
return mammoth.convertToHtml({path: docxPath}).then(function(result) {