summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-05-28 19:16:44 +0100
committerMichael Williamson <mike@zwobble.org>2023-05-28 19:16:44 +0100
commite12c1e59acd5fc66ec274395f3c0f88713daf5b4 (patch)
treeeb034934fee35f0885fccc65d64a6580ed45f2e3 /test
parent84fffea3212510a7b0b1d33b8dad4a9660675c8b (diff)
Add toArrayBuffer when embedding a style map
Diffstat (limited to 'test')
-rw-r--r--test/mammoth.tests.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/test/mammoth.tests.js b/test/mammoth.tests.js
index 9f0e902..3b1726e 100644
--- a/test/mammoth.tests.js
+++ b/test/mammoth.tests.js
@@ -122,14 +122,33 @@ test('embedded style maps can be disabled', function() {
});
});
-test('embedded style map can be written and then read', function() {
+test('embedded style map can be written using toBuffer() and then read', function() {
var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
return promises.nfcall(fs.readFile, docxPath)
.then(function(buffer) {
return mammoth.embedStyleMap({buffer: buffer}, "p => h1");
})
.then(function(docx) {
- return mammoth.convertToHtml({buffer: docx.toBuffer()});
+ var buffer = docx.toBuffer();
+ assert.ok(Buffer.isBuffer(buffer));
+ return mammoth.convertToHtml({buffer: buffer});
+ })
+ .then(function(result) {
+ assert.equal(result.value, "<h1>Walking on imported air</h1>");
+ assert.deepEqual(result.messages, []);
+ });
+});
+
+test('embedded style map can be written using toArrayBuffer() and then read', function() {
+ var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
+ return promises.nfcall(fs.readFile, docxPath)
+ .then(function(buffer) {
+ return mammoth.embedStyleMap({buffer: buffer}, "p => h1");
+ })
+ .then(function(docx) {
+ var arrayBuffer = docx.toArrayBuffer();
+ assert.ok(!Buffer.isBuffer(arrayBuffer));
+ return mammoth.convertToHtml({buffer: Buffer.from(arrayBuffer)});
})
.then(function(result) {
assert.equal(result.value, "<h1>Walking on imported air</h1>");