diff options
| -rw-r--r-- | lib/document-to-html.js | 6 | ||||
| -rw-r--r-- | test/document-to-html.tests.js | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js index eb7c8e1..bc61e34 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -247,7 +247,7 @@ function DocumentConversion(options, comments) { return findHtmlPath(reference, htmlPaths.ignore).wrap(function() { var comment = comments[reference.commentId]; var count = referencedComments.length + 1; - var label = "[" + comment.authorInitials + count + "]"; + var label = "[" + commentAuthorLabel(comment) + count + "]"; referencedComments.push({label: label, comment: comment}); // TODO: remove duplication with note references return [ @@ -393,3 +393,7 @@ function walkHtml(nodes, callback) { } }); } + +var commentAuthorLabel = exports.commentAuthorLabel = function commentAuthorLabel(comment) { + return comment.authorInitials || ""; +}; diff --git a/test/document-to-html.tests.js b/test/document-to-html.tests.js index af08050..cc8aff5 100644 --- a/test/document-to-html.tests.js +++ b/test/document-to-html.tests.js @@ -2,7 +2,9 @@ var assert = require("assert"); var promises = require("../lib/promises"); var documents = require("../lib/documents"); -var DocumentConverter = require("../lib/document-to-html").DocumentConverter; +var documentToHtml = require("../lib/document-to-html"); +var DocumentConverter = documentToHtml.DocumentConverter; +var commentAuthorLabel = documentToHtml.commentAuthorLabel; var test = require("./test")(module); var htmlPaths = require("../lib/html-paths"); var xml = require("../lib/xml"); @@ -612,3 +614,13 @@ function runOfText(text, properties) { var textElement = new documents.Text(text); return new documents.Run([textElement], properties); } + +test('when initials are not blank then comment author label is initials', function() { + assert.equal(commentAuthorLabel({authorInitials: "TP"}), "TP") +}); + +test('when initials are blank then comment author label is blank', function() { + assert.equal(commentAuthorLabel({authorInitials: ""}), "") + assert.equal(commentAuthorLabel({authorInitials: undefined}), "") + assert.equal(commentAuthorLabel({authorInitials: null}), "") +}); |
