From e3891290bd3034d0ce8034387ffab1e5a9793a70 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 29 Mar 2013 20:42:38 +0000 Subject: Add basic style mappings for paragraphs --- tests/documents.tests.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'tests/documents.tests.js') diff --git a/tests/documents.tests.js b/tests/documents.tests.js index 76f237e..a5e81af 100644 --- a/tests/documents.tests.js +++ b/tests/documents.tests.js @@ -14,7 +14,7 @@ describe('DocumentConverter', function() { return converter.convertToHtml(document).then(function(result) { assert.equal("

Hello.

", result.html); }); - }) + }); test('should convert document containing multiple paragraphs to multiple p elements', function() { var document = new documents.Document([ @@ -25,12 +25,28 @@ describe('DocumentConverter', function() { return converter.convertToHtml(document).then(function(result) { assert.equal("

Hello.

Goodbye.

", result.html); }); - }) + }); + + test('uses style mappings to pick HTML element for docx paragraph', function() { + var document = new documents.Document([ + paragraphOfText("Hello.", "Heading1"), + ]); + var converter = new DocumentConverter({ + paragraphStyleMap: { + "Heading1": "h1" + } + }); + return converter.convertToHtml(document).then(function(result) { + assert.equal("

Hello.

", result.html); + }); + }); }); -function paragraphOfText(text) { +function paragraphOfText(text, styleName) { var run = runOfText(text); - return new documents.Paragraph([run]); + return new documents.Paragraph([run], { + styleName: styleName + }); } function runOfText(text) { -- cgit v1.2.3