aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2017-05-18 19:38:58 +0100
committerMichael Williamson <mike@zwobble.org>2017-05-18 19:39:32 +0100
commit9aae75f64568055ef1c04a6a5f2bfb29cf7cf736 (patch)
treed0e6756979d871b5a9a22f8e886a8dcce0cb66de /test
parent327b99803151111bcec37af0d2bc5df5baa3506b (diff)
Add anchor on hyperlinks as fragment if present
Diffstat (limited to 'test')
-rw-r--r--test/docx/body-reader.tests.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js
index 7828cdb..351249a 100644
--- a/test/docx/body-reader.tests.js
+++ b/test/docx/body-reader.tests.js
@@ -878,7 +878,7 @@ function assertChildrenAreConvertedNormally(tagName) {
assert.deepEqual(result.value[0].type, "run");
}
-test("w:hyperlink is read as document hyperlink if it has a relationship ID", function() {
+test("w:hyperlink is read as external hyperlink if it has a relationship ID", function() {
var runXml = new XmlElement("w:r", {}, []);
var hyperlinkXml = new XmlElement("w:hyperlink", {"r:id": "r42"}, [runXml]);
var relationships = {
@@ -889,7 +889,18 @@ test("w:hyperlink is read as document hyperlink if it has a relationship ID", fu
assert.deepEqual(result.value.children[0].type, "run");
});
-test("w:hyperlink is read as document hyperlink if it has an anchor", function() {
+test("w:hyperlink is read as external hyperlink if it has a relationship ID and an anchor", function() {
+ var runXml = new XmlElement("w:r", {}, []);
+ var hyperlinkXml = new XmlElement("w:hyperlink", {"r:id": "r42", "w:anchor": "fragment"}, [runXml]);
+ var relationships = {
+ "r42": {target: "http://example.com/"}
+ };
+ var result = readXmlElement(hyperlinkXml, {relationships: relationships});
+ assert.deepEqual(result.value.href, "http://example.com/#fragment");
+ assert.deepEqual(result.value.children[0].type, "run");
+});
+
+test("w:hyperlink is read as internal hyperlink if it has an anchor", function() {
var runXml = new XmlElement("w:r", {}, []);
var hyperlinkXml = new XmlElement("w:hyperlink", {"w:anchor": "_Peter"}, [runXml]);
var result = readXmlElement(hyperlinkXml);