summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2017-02-19 19:11:13 +0000
committerMichael Williamson <mike@zwobble.org>2017-02-19 19:11:13 +0000
commit4f8ce5add5f14cd021d20b59acbc7e2d43d34caf (patch)
treeaa05d8b905437a9529414769752b85d4fd0d5d94 /test
parent40e958c90486dae503111ae82b9966d706d0e8fd (diff)
Extract duplicated matcher code
Diffstat (limited to 'test')
-rw-r--r--test/docx/body-reader.tests.js73
1 files changed, 19 insertions, 54 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js
index f4ee5d9..a7633a8 100644
--- a/test/docx/body-reader.tests.js
+++ b/test/docx/body-reader.tests.js
@@ -155,6 +155,16 @@ test("complex fields", (function() {
xml.text(' HYPERLINK "' + uri + '"')
]);
var hyperlinkRunXml = runOfText("this is a hyperlink");
+
+ var isEmptyHyperlinkedRun = isHyperlinkedRun({children: []});
+
+ function isHyperlinkedRun(hyperlinkProperties) {
+ return isRun({
+ children: contains(
+ isHyperlink(_.extend({href: uri}, hyperlinkProperties))
+ )
+ });
+ }
return {
"stores instrText returns empty result": function() {
@@ -175,22 +185,10 @@ test("complex fields", (function() {
assertThat(paragraph.children, contains(
isEmptyRun,
- isRun({
+ isEmptyHyperlinkedRun,
+ isHyperlinkedRun({
children: contains(
- isHyperlink({
- href: uri,
- children: []
- })
- )
- }),
- isRun({
- children: contains(
- isHyperlink({
- href: uri,
- children: contains(
- isText("this is a hyperlink")
- )
- })
+ isText("this is a hyperlink")
)
}),
isEmptyRun
@@ -210,14 +208,7 @@ test("complex fields", (function() {
assertThat(paragraph.children, contains(
isEmptyRun,
- isRun({
- children: contains(
- isHyperlink({
- href: uri,
- children: []
- })
- )
- }),
+ isEmptyHyperlinkedRun,
isEmptyRun,
isRun({
children: contains(
@@ -246,22 +237,10 @@ test("complex fields", (function() {
assertThat(paragraph.children, contains(
isEmptyRun,
- isRun({
- children: contains(
- isHyperlink({
- href: uri,
- children: []
- })
- )
- }),
- isRun({
+ isEmptyHyperlinkedRun,
+ isHyperlinkedRun({
children: contains(
- isHyperlink({
- href: uri,
- children: contains(
- isText("this is a hyperlink")
- )
- })
+ isText("this is a hyperlink")
)
}),
isEmptyRun
@@ -285,29 +264,15 @@ test("complex fields", (function() {
]);
var paragraph = readXmlElementValue(paragraphXml);
- var isEmptyHyperlinkedRun = isRun({
- children: contains(
- isHyperlink({
- href: uri,
- children: []
- })
- )
- });
-
assertThat(paragraph.children, contains(
isEmptyRun,
isEmptyHyperlinkedRun,
isEmptyHyperlinkedRun,
isEmptyHyperlinkedRun,
isEmptyHyperlinkedRun,
- isRun({
+ isHyperlinkedRun({
children: contains(
- isHyperlink({
- href: uri,
- children: contains(
- isText("this is a hyperlink")
- )
- })
+ isText("this is a hyperlink")
)
}),
isEmptyRun