diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-04-02 23:17:11 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-04-02 23:17:11 +0100 |
| commit | b346be31b8103d403134f12141b51f3321a6f442 (patch) | |
| tree | 67ebdb18b570756eb76c2c8d221317747b8286d1 /tests | |
| parent | cf81751b61fac1042623839d902ae31124d1f5fc (diff) | |
Write altText of image if available
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/document-to-html.tests.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index f8ea482..e7d65e7 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -5,6 +5,7 @@ var documents = require("../lib/documents"); var DocumentConverter = require("../lib/document-to-html").DocumentConverter; var test = require("./testing").test; var styles = require("../lib/styles"); +var xmlreader = require("../lib/xmlreader"); describe('DocumentConverter', function() { @@ -164,6 +165,25 @@ describe('DocumentConverter', function() { assert.equal(result.html, '<img src="data:image/png;base64,' + imageBuffer.toString("base64") + '" />'); }); }); + + test('images have alt attribute if available', function() { + var imageBuffer = new Buffer("Not an image at all!"); + var image = new documents.Image( + function() { + return q.when(imageBuffer); + }, + "It's a hat" + ); + var converter = new DocumentConverter(); + return converter.convertToHtml(image) + .then(function(result) { + return xmlreader.read(result.html); + }) + .then(function(htmlImageElementDocument) { + var htmlImageElement = htmlImageElementDocument.root; + assert.equal(htmlImageElement.attributes.alt, "It's a hat"); + }); + }); }); function paragraphOfText(text, styleName) { |
