From c0a14c171f5bdfda6cb76b1589a43ada3b5768ce Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 7 Jul 2016 21:27:53 +0100 Subject: Add conversion of comments --- test/document-to-html.tests.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/document-to-html.tests.js b/test/document-to-html.tests.js index 436014f..af08050 100644 --- a/test/document-to-html.tests.js +++ b/test/document-to-html.tests.js @@ -486,7 +486,7 @@ test('footnotes are included after the main body', function() { }); test('comments are ignored by default', function() { - var reference = documents.commentReference("4"); + var reference = documents.commentReference({commentId: "4"}); var comment = documents.comment({ commentId: "4", body: [paragraphOfText("Who's there?")] @@ -503,7 +503,37 @@ test('comments are ignored by default', function() { assert.equal(result.value, '

Knock knock

'); assert.deepEqual(result.messages, []); }); +}); +test('comment references are linked to comment after main body', function() { + var reference = documents.commentReference({commentId: "4"}); + var comment = documents.comment({ + commentId: "4", + body: [paragraphOfText("Who's there?")], + authorName: "The Piemaker", + authorInitials: "TP" + }); + var document = documents.document([ + documents.paragraph([ + runOfText("Knock knock"), + documents.run([reference]) + ]) + ], {comments: [comment]}); + + var converter = new DocumentConverter({ + idPrefix: "doc-42-", + styleMap: [ + {from: documentMatchers.commentReference, to: htmlPaths.element("sup")} + ] + }); + return converter.convertToHtml(document).then(function(result) { + var expectedHtml = ( + '

Knock knock[TP1]

' + + '
Comment [TP1]

Who\'s there? ↑

' + ); + assert.equal(result.value, expectedHtml); + assert.deepEqual(result.messages, []); + }); }); test('images are written with data URIs', function() { -- cgit v1.2.3