From a52d99fd85061a9f20b481535407a225d5927434 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 17 Jun 2015 15:40:21 +0100 Subject: Allow strikethrough to be configured in style mapping --- tests/document-to-html.tests.js | 15 +++++++++++++++ tests/mammoth.tests.js | 7 +++++++ tests/style-reader.tests.js | 7 +++++++ 3 files changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index 02079cd..2088f12 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -210,6 +210,21 @@ describe('DocumentConverter', function() { }); }); + test('strikethrough runs can be configured with style mapping', function() { + var run = runOfText("Hello.", {isStrikethrough: true}); + var converter = new DocumentConverter({ + styleMap: [ + { + from: documentMatchers.strikethrough, + to: htmlPaths.elements([htmlPaths.element("del")]) + } + ] + }); + return converter.convertToHtml(run).then(function(result) { + assert.equal(result.value, "Hello."); + }); + }); + test('style mapping for underline runs does not close parent elements', function() { var run = runOfText("Hello.", {isUnderline: true, isBold: true}); var converter = new DocumentConverter({ diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index cdc14e5..d4d7ef4 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -231,6 +231,13 @@ describe('mammoth', function() { }); }); + test('strikethrough conversion can be configured with style mappings', function() { + var docxPath = path.join(__dirname, "test-data/strikethrough.docx"); + return mammoth.convertToHtml({path: docxPath}, {styleMap: "strike => del"}).then(function(result) { + assert.equal(result.value, "

Today's Special: Salmon Sold out

"); + }); + }); + test('indentation is used if prettyPrint is true', function() { var docxPath = path.join(__dirname, "test-data/single-paragraph.docx"); return mammoth.convertToHtml({path: docxPath}, {prettyPrint: true}).then(function(result) { diff --git a/tests/style-reader.tests.js b/tests/style-reader.tests.js index 59d7c51..bfe61dc 100644 --- a/tests/style-reader.tests.js +++ b/tests/style-reader.tests.js @@ -100,6 +100,13 @@ describe("styleReader.readDocumentMatcher", function() { documentMatchers.underline ); }); + + test("reads strikethrough", function() { + assert.deepEqual( + readDocumentMatcher("strike"), + documentMatchers.strikethrough + ); + }); }); describe("styleReader.read", function() { -- cgit v1.2.3