aboutsummaryrefslogtreecommitdiff
path: root/tests/buffer-tests.js
diff options
context:
space:
mode:
authorChris Price <studiochris@users.noreply.github.com>2014-08-17 16:50:20 -0400
committerMichael Williamson <mike@zwobble.org>2014-08-18 12:41:47 +0100
commit86564e37ae9433d9678e0c00c66e342afd8884b0 (patch)
tree80a627e054185299e5be13a687b3907c7244ad93 /tests/buffer-tests.js
parent90f0b6d73e27a5490648523648b426bcab9b602f (diff)
Add support for reading .docx files from Buffer instances
Diffstat (limited to 'tests/buffer-tests.js')
-rw-r--r--tests/buffer-tests.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/buffer-tests.js b/tests/buffer-tests.js
new file mode 100644
index 0000000..3b4a6c1
--- /dev/null
+++ b/tests/buffer-tests.js
@@ -0,0 +1,27 @@
+var assert = require("assert");
+var test = require("./testing").test;
+
+var fs = require("fs");
+var path = require("path");
+
+var mammoth = require("../lib");
+
+describe("buffer-tests", function() {
+ test('should convert docx as Buffer to one HTML paragraph', function() {
+ var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
+ var buffer = fs.readFileSync(docxPath);
+ return mammoth.convertToHtml({buffer: buffer}).then(function(result) {
+ assert.equal(result.value, "<p>Walking on imported air</p>");
+ assert.deepEqual(result.messages, []);
+ });
+ });
+
+ test('should convert docx as Buffer to plain text', function() {
+ var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
+ var buffer = fs.readFileSync(docxPath);
+ return mammoth.extractRawText({buffer: buffer}).then(function(result) {
+ assert.equal(result.value, "Walking on imported air\n\n");
+ assert.deepEqual(result.messages, []);
+ });
+ });
+});