aboutsummaryrefslogtreecommitdiff
path: root/test/docx/body-reader.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2017-02-16 11:20:25 +0000
committerMichael Williamson <mike@zwobble.org>2017-02-16 11:20:25 +0000
commit7a738f5b619de07eca4bd5e49259912a839b15d2 (patch)
tree776c507cc877c78a367d1d613ffe66d0754f85ac /test/docx/body-reader.tests.js
parentfdd4a4d329a647912fd48991472ff61996684862 (diff)
Remove explicit indices in test
Diffstat (limited to 'test/docx/body-reader.tests.js')
-rw-r--r--test/docx/body-reader.tests.js42
1 files changed, 28 insertions, 14 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js
index 147684f..9bd2e34 100644
--- a/test/docx/body-reader.tests.js
+++ b/test/docx/body-reader.tests.js
@@ -3,6 +3,7 @@ var path = require("path");
var _ = require("underscore");
var hamjest = require("hamjest");
+var assertThat = hamjest.assertThat;
var promiseThat = hamjest.promiseThat;
var allOf = hamjest.allOf;
var contains = hamjest.contains;
@@ -10,6 +11,12 @@ var hasProperties = hamjest.hasProperties;
var willBe = hamjest.willBe;
var FeatureMatcher = hamjest.FeatureMatcher;
+var documentMatchers = require("./document-matchers");
+var isEmptyRun = documentMatchers.isEmptyRun;
+var isHyperlink = documentMatchers.isHyperlink;
+var isRun = documentMatchers.isRun;
+var isText = documentMatchers.isText;
+
var BodyReader = require("../../lib/docx/body-reader").BodyReader;
var documents = require("../../lib/documents");
var xml = require("../../lib/xml");
@@ -166,20 +173,27 @@ test("runs in a complex field for hyperlinks are read as hyperlinks", function()
afterEndXml
]);
var paragraph = readXmlElementValue(parXml);
-
- var hyperlinkRun = paragraph.children[1];
- var hyperlink = hyperlinkRun.children[0];
- assert.equal(hyperlink.type, 'hyperlink');
- assert.equal(hyperlink.href, uri);
- var hyperlinkText = hyperlink.children[0];
- assert.equal(hyperlinkText.type, 'text');
- assert.equal(hyperlinkText.value, 'this is a hyperlink');
-
- // runs after fldCharType "end" do not become hyperlinks
- var run = paragraph.children[3];
- var text = run.children[0];
- assert.equal(text.type, 'text');
- assert.equal(text.value, 'this will not be a hyperlink');
+
+ assertThat(paragraph.children, contains(
+ isEmptyRun,
+ isRun({
+ children: contains(
+ isHyperlink({
+ href: uri,
+ children: contains(
+ isText("this is a hyperlink")
+ )
+ })
+ )
+ }),
+ isEmptyRun,
+ isRun({
+ // runs after fldCharType "end" do not become hyperlinks
+ children: contains(
+ isText("this will not be a hyperlink")
+ )
+ })
+ ));
});
test("run has no style if it has no properties", function() {