aboutsummaryrefslogtreecommitdiff
path: root/test/docx/docx-reader.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2018-01-26 23:30:13 +0000
committerMichael Williamson <mike@zwobble.org>2018-01-26 23:30:13 +0000
commit8b9ca6ca68fec89926cfb02a96506bbee54a5b2c (patch)
tree34f701ec9078d533d86ad63fc6aa11dbd91ad278 /test/docx/docx-reader.tests.js
parent9196e8bc6f2ff2c59a9b4fde4813e7bc26b8c23d (diff)
Find comments part using document relationships
Diffstat (limited to 'test/docx/docx-reader.tests.js')
-rw-r--r--test/docx/docx-reader.tests.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/docx/docx-reader.tests.js b/test/docx/docx-reader.tests.js
index 0556405..0d51f45 100644
--- a/test/docx/docx-reader.tests.js
+++ b/test/docx/docx-reader.tests.js
@@ -113,5 +113,43 @@ test("part paths", {
return docxReader._findPartPaths(docxFile).then(function(partPaths) {
assert.equal(partPaths.mainDocument, "word/document.xml");
});
+ },
+
+ "comments part is found using main document relationships": function() {
+ var docxFile = createFakeDocxFile({
+ "_rels/.rels": createPackageRelationships("word/document.xml"),
+ "word/document.xml": " ",
+ "word/_rels/document.xml.rels": xml.writeString(xml.element("r:Relationships", {}, [
+ xml.element("r:Relationship", {
+ "Type": "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
+ "Target": "comments2.xml"
+ })
+ ]), relationshipNamespaces),
+ "word/comments2.xml": " "
+ });
+ return docxReader._findPartPaths(docxFile).then(function(partPaths) {
+ assert.equal(partPaths.comments, "word/comments2.xml");
+ });
+ },
+
+ "word/comments.xml is used as fallback location for comments part": function() {
+ var docxFile = createFakeDocxFile({
+ "_rels/.rels": createPackageRelationships("word/document.xml"),
+ "word/document.xml": " ",
+ "word/comments.xml": " "
+ });
+ return docxReader._findPartPaths(docxFile).then(function(partPaths) {
+ assert.equal(partPaths.comments, "word/comments.xml");
+ });
}
});
+
+
+function createPackageRelationships(mainDocumentPath) {
+ return xml.writeString(xml.element("r:Relationships", {}, [
+ xml.element("r:Relationship", {
+ "Type": "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
+ "Target": mainDocumentPath
+ })
+ ]), relationshipNamespaces);
+}