aboutsummaryrefslogtreecommitdiff
path: root/test/docx/comments-reader.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-07-03 19:43:00 +0100
committerMichael Williamson <mike@zwobble.org>2016-07-03 19:43:00 +0100
commitba731d3c8a9408b9d33deb63e0492b54298169c5 (patch)
treeaa7ab6403bdfd8d923c6b9e86eeccf006dcb09ca /test/docx/comments-reader.tests.js
parentd98f3862193c6bb9b88735c131531ac6b1f7b5c0 (diff)
Read author name and initials for each comment
Diffstat (limited to 'test/docx/comments-reader.tests.js')
-rw-r--r--test/docx/comments-reader.tests.js45
1 files changed, 44 insertions, 1 deletions
diff --git a/test/docx/comments-reader.tests.js b/test/docx/comments-reader.tests.js
index 55cffeb..2902f29 100644
--- a/test/docx/comments-reader.tests.js
+++ b/test/docx/comments-reader.tests.js
@@ -7,8 +7,9 @@ var xml = require("../../lib/xml");
var test = require("../test")(module);
+var bodyReader = new BodyReader({});
+
test('ID and body of comment are read', function() {
- var bodyReader = new BodyReader({});
var body = [xml.element("w:p")];
var comments = createCommentsReader(bodyReader)({
root: xml.element("w:comments", {}, [
@@ -19,3 +20,45 @@ test('ID and body of comment are read', function() {
assert.deepEqual(comments.value[0].body, [new documents.Paragraph([])]);
assert.deepEqual(comments.value[0].commentId, "1");
});
+
+
+test('when optional attributes of comment are missing then they are read as null', function() {
+ var body = [xml.element("w:p")];
+ var comments = createCommentsReader(bodyReader)({
+ root: xml.element("w:comments", {}, [
+ xml.element("w:comment", {"w:id": "1"}, body)
+ ])
+ });
+ assert.equal(comments.value.length, 1);
+ var comment = comments.value[0];
+ assert.strictEqual(comment.authorName, null);
+ assert.strictEqual(comment.authorInitials, null);
+});
+
+
+test('when optional attributes of comment are blank then they are read as null', function() {
+ var body = [xml.element("w:p")];
+ var comments = createCommentsReader(bodyReader)({
+ root: xml.element("w:comments", {}, [
+ xml.element("w:comment", {"w:id": "1", "w:author": " ", "w:initials": " "}, body)
+ ])
+ });
+ assert.equal(comments.value.length, 1);
+ var comment = comments.value[0];
+ assert.strictEqual(comment.authorName, null);
+ assert.strictEqual(comment.authorInitials, null);
+});
+
+
+test('when optional attributes of comment are not blank then they are read', function() {
+ var body = [xml.element("w:p")];
+ var comments = createCommentsReader(bodyReader)({
+ root: xml.element("w:comments", {}, [
+ xml.element("w:comment", {"w:id": "1", "w:author": "The Piemaker", "w:initials": "TP"}, body)
+ ])
+ });
+ assert.equal(comments.value.length, 1);
+ var comment = comments.value[0];
+ assert.strictEqual(comment.authorName, "The Piemaker");
+ assert.strictEqual(comment.authorInitials, "TP");
+});