diff options
| author | Andrej T <andrejtrajchevski@gmail.com> | 2016-07-06 14:16:09 +0200 |
|---|---|---|
| committer | Andrej T <andrejtrajchevski@gmail.com> | 2016-07-06 14:16:09 +0200 |
| commit | 4b679e95712b732d07be105f7067de34b41493ec (patch) | |
| tree | 2cab5ee0a23eeb774d8c089c4c69513f780b4a2c | |
| parent | 60f36a1a20b34a0907aeb1af013f0f6ed97e45df (diff) | |
results.error now also accepts string as arg; changed img test to expect error
| -rw-r--r-- | lib/results.js | 17 | ||||
| -rw-r--r-- | test/mammoth.tests.js | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/results.js b/lib/results.js index 043f1f9..2c89be3 100644 --- a/lib/results.js +++ b/lib/results.js @@ -46,11 +46,18 @@ function warning(message) { } function error(exception) { - return { - type: "error", - message: exception.message, - stack: exception.stack - }; + if (typeof exception == 'string') { + return { + type: "error", + message: exception + }; + } else { + return { + type: "error", + message: exception.message, + stack: exception.stack + }; + } } function combineMessages(results) { diff --git a/test/mammoth.tests.js b/test/mammoth.tests.js index 1a82014..622fcbb 100644 --- a/test/mammoth.tests.js +++ b/test/mammoth.tests.js @@ -197,7 +197,7 @@ describe('mammoth', function() { var buffer = fs.readFileSync(docxPath); return mammoth.convertToHtml({buffer: buffer}).then(function(result) { assert.equal(result.value, ''); - assert.deepEqual(result.messages, [results.warning("could not find external image 'tiny-picture.png', path of input document is unknown")]); + assert.equal(result.messages[0].message, results.error("could not find external image 'tiny-picture.png', path of input document is unknown").message); }); }); |
