diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-11-19 14:53:45 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-11-19 14:53:45 +0000 |
| commit | a7146d18d1183fbe0203025f5e0e6aee5cd3775c (patch) | |
| tree | 0742a812f4488265ca33ff7221bd97b78c500e53 /test | |
| parent | 599b3f17555a9d0c03ff040df6dca232b152a6f0 (diff) | |
Include embedded style map when explicit style map is set
Diffstat (limited to 'test')
| -rw-r--r-- | test/mammoth.tests.js | 11 | ||||
| -rw-r--r-- | test/options-reader.tests.js | 29 |
2 files changed, 30 insertions, 10 deletions
diff --git a/test/mammoth.tests.js b/test/mammoth.tests.js index db2b338..19e0c47 100644 --- a/test/mammoth.tests.js +++ b/test/mammoth.tests.js @@ -100,6 +100,17 @@ test('explicit style map takes precedence over embedded style map', function() { }); }); +test('embedded style maps can be disabled', function() { + var docxPath = path.join(__dirname, "test-data/embedded-style-map.docx"); + var options = { + includeEmbeddedStyleMap: false + }; + return mammoth.convertToHtml({path: docxPath}, options).then(function(result) { + assert.equal(result.value, "<p>Walking on imported air</p>"); + assert.deepEqual(result.messages, []); + }); +}); + test('embedded style map can be written and then read', function() { var docxPath = path.join(__dirname, "test-data/single-paragraph.docx"); return promises.nfcall(fs.readFile, docxPath) diff --git a/test/options-reader.tests.js b/test/options-reader.tests.js index b0f202b..bad4c56 100644 --- a/test/options-reader.tests.js +++ b/test/options-reader.tests.js @@ -1,5 +1,7 @@ var assert = require("assert"); +var _ = require("underscore"); + var optionsReader = require("../lib/options-reader"); var standardOptions = optionsReader._standardOptions; var readOptions = optionsReader.readOptions; @@ -7,42 +9,49 @@ var test = require("./test")(module); test('standard options are used if options is undefined', function() { - assert.deepEqual(standardOptions, readOptions(undefined)); + var options = readOptions(undefined); + assert.deepEqual(standardOptions, _.omit(options, "customStyleMap", "readStyleMap")); + assert.deepEqual(options.customStyleMap, []); }); test('standard options are used if options is empty', function() { - assert.deepEqual(standardOptions, readOptions({})); + var options = readOptions({}); + assert.deepEqual(standardOptions, _.omit(options, "customStyleMap", "readStyleMap")); + assert.deepEqual(options.customStyleMap, []); }); test('custom style map as string is prepended to standard style map', function() { var options = readOptions({ styleMap: "p.SectionTitle => h2" }); - assert.deepEqual("p.SectionTitle => h2", options.styleMap[0]); - assert.deepEqual(standardOptions.styleMap, options.styleMap.slice(1)); + var styleMap = options.readStyleMap(); + assert.deepEqual("p.SectionTitle => h2", styleMap[0]); + assert.deepEqual(optionsReader._defaultStyleMap, styleMap.slice(1)); }); test('custom style map as array is prepended to standard style map', function() { var options = readOptions({ styleMap: ["p.SectionTitle => h2"] }); - assert.deepEqual("p.SectionTitle => h2", options.styleMap[0]); - assert.deepEqual(standardOptions.styleMap, options.styleMap.slice(1)); + var styleMap = options.readStyleMap(); + assert.deepEqual("p.SectionTitle => h2", styleMap[0]); + assert.deepEqual(optionsReader._defaultStyleMap, styleMap.slice(1)); }); test('lines starting with # in custom style map are ignored', function() { var options = readOptions({ styleMap: "# p.SectionTitle => h3\np.SectionTitle => h2" }); - assert.deepEqual("p.SectionTitle => h2", options.styleMap[0]); - assert.deepEqual(standardOptions.styleMap, options.styleMap.slice(1)); + var styleMap = options.readStyleMap(); + assert.deepEqual("p.SectionTitle => h2", styleMap[0]); + assert.deepEqual(optionsReader._defaultStyleMap, styleMap.slice(1)); }); test('blank lines in custom style map are ignored', function() { var options = readOptions({ styleMap: "\n\n" }); - assert.deepEqual(standardOptions.styleMap, options.styleMap); + assert.deepEqual(optionsReader._defaultStyleMap, options.readStyleMap()); }); test('default style mappings are ignored if includeDefaultStyleMap is false', function() { @@ -50,5 +59,5 @@ test('default style mappings are ignored if includeDefaultStyleMap is false', fu styleMap: "p.SectionTitle => h2", includeDefaultStyleMap: false }); - assert.deepEqual(["p.SectionTitle => h2"], options.styleMap); + assert.deepEqual(["p.SectionTitle => h2"], options.readStyleMap()); }); |
