From c42714e5f4b643de27b106a084601e39b7e5d04c Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 28 Aug 2016 19:44:42 +0100 Subject: Throw more informative error when word/document.xml cannot be found --- test/mammoth.tests.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/mammoth.tests.js') diff --git a/test/mammoth.tests.js b/test/mammoth.tests.js index f4d445b..bf3d2fd 100644 --- a/test/mammoth.tests.js +++ b/test/mammoth.tests.js @@ -368,3 +368,13 @@ test('extractRawText can use .docx files represented by a Buffer', function() { assert.deepEqual(result.messages, []); }); }); + + +test('should throw error if file is not a valid docx document', function() { + var docxPath = path.join(__dirname, "test-data/empty.zip"); + return mammoth.convertToHtml({path: docxPath}).then(function(result) { + assert.ok(false, "Expected error"); + }, function(error) { + assert.equal(error.message, "Could not find word/document.xml in ZIP file. Are you sure this is a valid .docx file?"); + }); +}); -- cgit v1.2.3