aboutsummaryrefslogtreecommitdiff
path: root/tests/mammoth.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-08-18 12:51:51 +0100
committerMichael Williamson <mike@zwobble.org>2014-08-18 12:51:51 +0100
commit275b87161b64d0ee2932acc488611d46f280ae75 (patch)
tree51748726cde9fb08aafa2560ee18eca3e3a966f7 /tests/mammoth.tests.js
parent86564e37ae9433d9678e0c00c66e342afd8884b0 (diff)
Rearrange buffer tests
Diffstat (limited to 'tests/mammoth.tests.js')
-rw-r--r--tests/mammoth.tests.js26
1 files changed, 26 insertions, 0 deletions
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, "<p>Walking on imported air</p>");
+ 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, []);
+ });
+ });
});