diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-08-28 20:03:00 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-08-28 20:03:00 +0100 |
| commit | d333cee1c7a7f95cadf5b59e8dbb0124d73852df (patch) | |
| tree | f837b57e640eb9bad909416c6822f6edb9d192ac /test/document-to-html.tests.js | |
| parent | b1ae23f544c479d2b71347bbf67df7baac40d78f (diff) | |
Add test explicitly for image error handling
Diffstat (limited to 'test/document-to-html.tests.js')
| -rw-r--r-- | test/document-to-html.tests.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/document-to-html.tests.js b/test/document-to-html.tests.js index cc8aff5..59eba49 100644 --- a/test/document-to-html.tests.js +++ b/test/document-to-html.tests.js @@ -590,6 +590,28 @@ test('can add custom handler for images', function() { }); }); +test('when custom image handler throws error then error is stored in error message', function() { + var error = new Error("Failed to convert image"); + var image = new documents.Image({ + readImage: function(encoding) { + return promises.when(new Buffer().toString(encoding)); + }, + contentType: "image/png" + }); + var converter = new DocumentConverter({ + convertImage: function(element, messages) { + throw error; + } + }); + return converter.convertToHtml(image).then(function(result) { + assert.equal(result.value, ''); + assert.equal(result.messages.length, 1); + var message = result.messages[0]; + assert.equal("error", message.type); + assert.equal("Failed to convert image", message.message); + }); +}); + test('long documents do not cause stack overflow', function() { var paragraphs = []; for (var i = 0; i < 1000; i++) { |
