aboutsummaryrefslogtreecommitdiff
path: root/test/docx/docx-reader.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-07-03 19:19:21 +0100
committerMichael Williamson <mike@zwobble.org>2016-07-03 19:20:00 +0100
commit0b56dfce42c3944cce47e284608e6806f4c839c3 (patch)
tree5f96f9c2908f1c5b00a7192e71d4c192abd7cf47 /test/docx/docx-reader.tests.js
parent627c4a755395e313234bdb1914d168392006c483 (diff)
Move tests to test for easier Mocha usage
Diffstat (limited to 'test/docx/docx-reader.tests.js')
-rw-r--r--test/docx/docx-reader.tests.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/docx/docx-reader.tests.js b/test/docx/docx-reader.tests.js
new file mode 100644
index 0000000..69ade7e
--- /dev/null
+++ b/test/docx/docx-reader.tests.js
@@ -0,0 +1,42 @@
+var assert = require("assert");
+
+var docxReader = require("../../lib/docx/docx-reader");
+var documents = require("../../lib/documents");
+
+var testing = require("../testing");
+var test = testing.test;
+var testData = testing.testData;
+var createFakeDocxFile = testing.createFakeDocxFile;
+
+
+describe("docx-reader", function() {
+ test("can read document with single paragraph with single run of text", function() {
+ var expectedDocument = documents.Document([
+ documents.Paragraph([
+ documents.Run([
+ documents.Text("Hello.")
+ ])
+ ])
+ ]);
+ var docxFile = createFakeDocxFile({
+ "word/document.xml": testData("simple/word/document.xml")
+ });
+ return docxReader.read(docxFile).then(function(result) {
+ assert.deepEqual(expectedDocument, result.value);
+ });
+ });
+
+ test("hyperlink hrefs are read from relationships file", function() {
+ var docxFile = createFakeDocxFile({
+ "word/document.xml": testData("hyperlinks/word/document.xml"),
+ "word/_rels/document.xml.rels": testData("hyperlinks/word/_rels/document.xml.rels")
+ });
+ return docxReader.read(docxFile).then(function(result) {
+ var paragraph = result.value.children[0];
+ assert.equal(1, paragraph.children.length);
+ var hyperlink = paragraph.children[0];
+ assert.equal(hyperlink.href, "http://www.example.com");
+ assert.equal(hyperlink.children.length, 1);
+ });
+ });
+});