aboutsummaryrefslogtreecommitdiff
path: root/test/docx/docx-reader.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2018-01-26 18:16:50 +0000
committerMichael Williamson <mike@zwobble.org>2018-01-26 18:16:50 +0000
commitf5fbc6e4aface5c6c9537b38d1650b0d37e3cbc1 (patch)
tree00dc33ece5cd79b72af7889dfb748e661104ab33 /test/docx/docx-reader.tests.js
parent818cedc5fd9e83a633df5fae5c341996abcd9e80 (diff)
Add tests for findPartPaths
Diffstat (limited to 'test/docx/docx-reader.tests.js')
-rw-r--r--test/docx/docx-reader.tests.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/docx/docx-reader.tests.js b/test/docx/docx-reader.tests.js
index 26f06ac..0556405 100644
--- a/test/docx/docx-reader.tests.js
+++ b/test/docx/docx-reader.tests.js
@@ -86,3 +86,32 @@ test("error is thrown when main document part does not exist", function() {
assert.equal(error.message, "Could not find main document part. Are you sure this is a valid .docx file?");
});
});
+
+
+test("part paths", {
+ "main document part is found using package relationships": function() {
+ var relationships = xml.element("r:Relationships", {}, [
+ xml.element("r:Relationship", {
+ "Type": "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
+ "Target": "/word/document2.xml"
+ })
+ ]);
+
+ var docxFile = createFakeDocxFile({
+ "word/document2.xml": " ",
+ "_rels/.rels": xml.writeString(relationships, relationshipNamespaces)
+ });
+ return docxReader._findPartPaths(docxFile).then(function(partPaths) {
+ assert.equal(partPaths.mainDocument, "word/document2.xml");
+ });
+ },
+
+ "word/document.xml is used as fallback location for main document part": function() {
+ var docxFile = createFakeDocxFile({
+ "word/document.xml": " "
+ });
+ return docxReader._findPartPaths(docxFile).then(function(partPaths) {
+ assert.equal(partPaths.mainDocument, "word/document.xml");
+ });
+ }
+});