From 9b9fc902b784090f4f6fafd866c7b35bf47f517f Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 27 Apr 2014 18:12:33 +0100 Subject: Throw error if somebody tries to use styleMapping() --- lib/index.js | 4 ++++ tests/mammoth.tests.js | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/index.js b/lib/index.js index baae852..35bcbaf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -25,3 +25,7 @@ function convertDocumentToHtml(documentResult, options) { return documentConverter.convertToHtml(document); }); } + +exports.styleMapping = function() { + throw new Error('Use a raw string instead of mammoth.styleMapping e.g. "p[style-naming=\'Title\'] => h1" instead of mammoth.styleMapping("p[style-naming=\'Title\'] => h1")'); +}; diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index 0c9519e..90b96e5 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -95,4 +95,15 @@ describe('mammoth', function() { assert.deepEqual(result.messages, []); }); }); + + test('using styleMapping throws error', function() { + try { + mammoth.styleMapping() + } catch (error) { + assert.equal( + error.message, + 'Use a raw string instead of mammoth.styleMapping e.g. "p[style-naming=\'Title\'] => h1" instead of mammoth.styleMapping("p[style-naming=\'Title\'] => h1")' + ); + } + }); }) -- cgit v1.2.3