From 57299a40f7517ac4934ac391b44656500bac024d Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 15 Aug 2015 10:00:12 +0100 Subject: Generate warnings for not-understood style mappings and continue --- tests/mammoth.tests.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/mammoth.tests.js') diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index 6fdd60f..64439f1 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -4,6 +4,7 @@ var fs = require("fs"); var mammoth = require("../"); var promises = require("../lib/promises"); +var results = require("../lib/results"); var testing = require("./testing"); var test = testing.test; @@ -95,6 +96,19 @@ describe('mammoth', function() { }); }); + test('warning if style mapping is not understood', function() { + var docxPath = path.join(__dirname, "test-data/single-paragraph.docx"); + var options = { + styleMap: "!!!!\np => h1" + }; + return mammoth.convertToHtml({path: docxPath}, options).then(function(result) { + assert.equal("

Walking on imported air

", result.value); + var warning = "Did not understand this style mapping, so ignored it: !!!!\n" + + 'Error was at character number 1: Expected element type but got unrecognisedCharacter "!"'; + assert.deepEqual(result.messages, [results.warning(warning)]); + }); + }); + test('options are passed to document converter when calling mammoth.convertToHtml', function() { var docxFile = createFakeDocxFile({ "word/document.xml": testData("simple/word/document.xml") -- cgit v1.2.3