From ad7500f87900f3db170c11c6cf997e0c7493babc Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 6 Jan 2014 22:06:44 +0000 Subject: Reduce to a single export --- tests/mammoth.tests.js | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index a7385ca..c78bc19 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -15,16 +15,15 @@ var createFakeDocxFile = testing.createFakeDocxFile; describe('mammoth', function() { - test('should convert docx containing one one paragraph to single p element', function() { + test('should convert docx containing one paragraph to single p element', function() { var docxPath = path.join(__dirname, "test-data/single-paragraph.docx"); - var converter = new mammoth.Converter(); - return converter.convertToHtml({path: docxPath}).then(function(result) { + return mammoth.convertToHtml({path: docxPath}).then(function(result) { assert.equal(result.value, "

Walking on imported air

"); assert.deepEqual(result.messages, []); }); }); - test('should convert Uint8Array containing one one paragraph to single p element', function() { + test('should convert Uint8Array containing one paragraph to single p element', function() { var docxPath = path.join(__dirname, "test-data/single-paragraph.docx"); return q.nfcall(fs.readFile, docxPath).then(function(buffer) { @@ -32,8 +31,7 @@ describe('mammoth', function() { for (var i = 0; i < buffer.length; i++) { array[i] = buffer[i]; } - var converter = new mammoth.Converter(); - return converter.convertToHtml({uint8Array: array}).then(function(result) { + return mammoth.convertToHtml({uint8Array: array}).then(function(result) { assert.equal("

Walking on imported air

", result.value); }); }); @@ -43,15 +41,10 @@ describe('mammoth', function() { var docxFile = createFakeDocxFile({ "word/document.xml": testData("simple/word/document.xml") }); - var converter = new mammoth.Converter({ - styleMap: [ - { - from: documentMatchers.paragraph(), - to: htmlPaths.topLevelElement("h1") - } - ] - }); - return converter.convertToHtml({file: docxFile}).then(function(result) { + var options = { + styleMap: "p => h1" + }; + return mammoth.convertToHtml({file: docxFile}, options).then(function(result) { assert.equal("

Hello.

", result.value); }); }); @@ -61,12 +54,7 @@ describe('mammoth', function() { "word/document.xml": testData("simple/word/document.xml") }); var options = { - styleMap: [ - { - from: documentMatchers.paragraph(), - to: htmlPaths.topLevelElement("h1") - } - ] + styleMap: "p => h1" }; return mammoth.convertToHtml({file: docxFile}, options).then(function(result) { assert.equal("

Hello.

", result.value); @@ -74,17 +62,15 @@ describe('mammoth', function() { }); test('inline images are included in output', function() { - var converter = new mammoth.Converter(); var docxPath = path.join(__dirname, "test-data/tiny-picture.docx"); - return converter.convertToHtml({path: docxPath}).then(function(result) { + return mammoth.convertToHtml({path: docxPath}).then(function(result) { assert.equal(result.value, '

'); }); }); test('simple list is converted to list elements', function() { - var converter = new mammoth.Converter(); var docxPath = path.join(__dirname, "test-data/simple-list.docx"); - return converter.convertToHtml({path: docxPath}).then(function(result) { + return mammoth.convertToHtml({path: docxPath}).then(function(result) { assert.equal(result.value, ''); }); }); -- cgit v1.2.3