From 62ccce26f2b44ecd5df06670d0e935d7d57d7d4d Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 31 Aug 2022 21:20:01 +0100 Subject: Only use the alt text of image elements as a fallback --- test/images.tests.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test') diff --git a/test/images.tests.js b/test/images.tests.js index 9a9344d..cd8d51b 100644 --- a/test/images.tests.js +++ b/test/images.tests.js @@ -83,5 +83,30 @@ test('mammoth.images.imgElement()', { }) )); }); + }, + + 'image alt text can be overriden by alt attribute returned from function': function() { + var imageBuffer = new Buffer("abc"); + var image = new documents.Image({ + readImage: function(encoding) { + return promises.when(imageBuffer.toString(encoding)); + }, + contentType: "image/jpeg", + altText: "" + }); + + var result = mammoth.images.imgElement(function(image) { + return {alt: "", src: ""}; + })(image); + + return result.then(function(result) { + assertThat(result, contains( + hasProperties({ + tag: hasProperties({ + attributes: equalTo({alt: "", src: ""}) + }) + }) + )); + }); } }); -- cgit v1.2.3