diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-04-28 12:52:24 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-04-28 12:52:24 +0100 |
| commit | 6b9aa0d1e370d2f982ed85882181e735fa4431d2 (patch) | |
| tree | abdea0a54ba60311790e5e96f60331a0ecf5e495 /tests | |
| parent | 8149a2ea6867b07a3f8b17e09ee0cd296bcfb329 (diff) | |
Allow custom image to HTML conversion
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/document-to-html.tests.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index c7b7bcf..65ce341 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -206,6 +206,27 @@ describe('DocumentConverter', function() { assert.equal(htmlImageElement.attributes.alt, "It's a hat"); }); }); + + test('can add custom handler for images', function() { + var imageBuffer = new Buffer("Not an image at all!"); + var image = new documents.Image({ + readImage: function(encoding) { + return q.when(imageBuffer.toString(encoding)); + }, + contentType: "image/png" + }); + var converter = new DocumentConverter({ + convertImage: function(element, html, messages, callback) { + element.read("utf8").then(function(altText) {; + html.selfClosing(htmlPaths.element("img", {alt: altText})); + callback(); + }); + } + }); + return converter.convertToHtml(image).then(function(result) { + assert.equal(result.value, '<img alt="Not an image at all!" />'); + }); + }); }); function paragraphOfText(text, styleName) { |
