From 275b87161b64d0ee2932acc488611d46f280ae75 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 18 Aug 2014 12:51:51 +0100 Subject: Rearrange buffer tests --- tests/mammoth.tests.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/mammoth.tests.js') diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index a14639d..e0c1f6c 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -1,7 +1,9 @@ var assert = require("assert"); var path = require("path"); +var fs = require("fs"); var mammoth = require("../"); +var promises = require("../lib/promises"); var testing = require("./testing"); var test = testing.test; @@ -18,6 +20,18 @@ describe('mammoth', function() { }); }); + test('should convert docx represented by a Buffer', function() { + var docxPath = path.join(__dirname, "test-data/single-paragraph.docx"); + return promises.nfcall(fs.readFile, docxPath) + .then(function(buffer) { + return mammoth.convertToHtml({buffer: buffer}); + }) + .then(function(result) { + assert.equal(result.value, "

Walking on imported air

"); + assert.deepEqual(result.messages, []); + }); + }); + test('style map can be expressed as string', function() { var docxFile = createFakeDocxFile({ "word/document.xml": testData("simple/word/document.xml") @@ -167,4 +181,16 @@ describe('mammoth', function() { assert.equal(result.value, 'Apple\n\nBanana\n\n'); }); }); + + test('extractRawText can use .docx files represented by a Buffer', function() { + var docxPath = path.join(__dirname, "test-data/single-paragraph.docx"); + return promises.nfcall(fs.readFile, docxPath) + .then(function(buffer) { + return mammoth.extractRawText({buffer: buffer}); + }) + .then(function(result) { + assert.equal(result.value, "Walking on imported air\n\n"); + assert.deepEqual(result.messages, []); + }); + }); }); -- cgit v1.2.3