From f5fbc6e4aface5c6c9537b38d1650b0d37e3cbc1 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 26 Jan 2018 18:16:50 +0000 Subject: Add tests for findPartPaths --- test/docx/docx-reader.tests.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test/docx/docx-reader.tests.js') 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"); + }); + } +}); -- cgit v1.2.3