aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-09-17 22:38:29 +0100
committerMichael Williamson <mike@zwobble.org>2026-09-17 22:38:50 +0100
commit003dcae99c0871ed44fd344576bc4bad37fb1222 (patch)
tree750391bb144365be994fdc97b40ed3f908976c29 /test
parent61762f3078f0c4aa822f8ad469746f51eb5b6165 (diff)
Add tests for .done() on promises returned by public API
Diffstat (limited to 'test')
-rw-r--r--test/mammoth.tests.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/mammoth.tests.js b/test/mammoth.tests.js
index 0291c6a..11cd583 100644
--- a/test/mammoth.tests.js
+++ b/test/mammoth.tests.js
@@ -520,3 +520,38 @@ test('should throw error if file is not a valid docx document', function() {
assert.equal(error.message, "Could not find main document part. Are you sure this is a valid .docx file?");
});
});
+
+test("Promise.done() is available", {
+ "on convertToHtml()": function() {
+ var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
+ return mammoth.convertToHtml({path: docxPath}).done();
+ },
+
+ "on convertToMarkdown()": function() {
+ var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
+ return mammoth.convertToMarkdown({path: docxPath}).done();
+ },
+
+ "on extractRawText()": function() {
+ var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
+ return mammoth.extractRawText({path: docxPath}).done();
+ },
+
+ "on embedStyleMap()": function() {
+ var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
+ return fs.readFile(docxPath).then(function(buffer) {
+ return mammoth.embedStyleMap({buffer: buffer}, "p => h1").done();
+ });
+ },
+
+ "on readEmbeddedStyleMap()": function() {
+ var docxPath = path.join(__dirname, "test-data/single-paragraph.docx");
+ return fs.readFile(docxPath)
+ .then(function(buffer) {
+ return mammoth.embedStyleMap({buffer: buffer}, "p => h1");
+ })
+ .then(function(docx) {
+ return mammoth.readEmbeddedStyleMap({buffer: docx.toBuffer()}).done();
+ });
+ }
+});