aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-07-07 21:37:21 +0100
committerMichael Williamson <mike@zwobble.org>2016-07-07 21:37:21 +0100
commitbf37d9d321dad98f3fa2ca99a5235d07cb66892e (patch)
tree46a51f532fba79a4cc19398e0aa4fda04b5debd4 /test
parentc0a14c171f5bdfda6cb76b1589a43ada3b5768ce (diff)
Wire up comment conversion code
Diffstat (limited to 'test')
-rw-r--r--test/mammoth.tests.js19
-rwxr-xr-xtest/test-data/comments.docxbin0 -> 15526 bytes
2 files changed, 19 insertions, 0 deletions
diff --git a/test/mammoth.tests.js b/test/mammoth.tests.js
index 12bee96..0515b2a 100644
--- a/test/mammoth.tests.js
+++ b/test/mammoth.tests.js
@@ -269,6 +269,25 @@ describe('mammoth', function() {
});
});
+ test('when style mapping is defined for comment references then comments are included', function() {
+ var docxPath = path.join(__dirname, "test-data/comments.docx");
+ var options = {
+ idPrefix: "doc-42-",
+ styleMap: "comment-reference => sup"
+ };
+ return mammoth.convertToHtml({path: docxPath}, options).then(function(result) {
+ var expectedOutput = (
+ '<p>Ouch' +
+ '<sup><a href="#doc-42-comment-0" id="doc-42-comment-ref-0">[MW1]</a></sup>.' +
+ '<sup><a href="#doc-42-comment-2" id="doc-42-comment-ref-2">[MW2]</a></sup></p>' +
+ '<dl><dt id="doc-42-comment-0">Comment [MW1]</dt><dd><p>A tachyon walks into a bar. <a href="#doc-42-comment-ref-0">↑</a></p></dd>' +
+ '<dt id="doc-42-comment-2">Comment [MW2]</dt><dd><p>Fin. <a href="#doc-42-comment-ref-2">↑</a></p></dd></dl>'
+ );
+ assert.equal(result.value, expectedOutput);
+ assert.deepEqual(result.messages, []);
+ });
+ });
+
test('textboxes are read', function() {
var docxPath = path.join(__dirname, "test-data/text-box.docx");
return mammoth.convertToHtml({path: docxPath}).then(function(result) {
diff --git a/test/test-data/comments.docx b/test/test-data/comments.docx
new file mode 100755
index 0000000..32cdae1
--- /dev/null
+++ b/test/test-data/comments.docx
Binary files differ