From 35df4eed2249ee7e582cca4d371a78ce92c44d2a Mon Sep 17 00:00:00 2001 From: Jonathan Lehman Date: Sat, 18 Feb 2017 11:48:22 -0500 Subject: Add test case for complex fields nested within a hyperlink complex field --- test/docx/body-reader.tests.js | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'test') diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index 1882f3a..a670202 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -308,6 +308,55 @@ test("complex fields", (function() { }), isEmptyRun )); + }, + + "complex field nested within a hyperlink complex field is wrapped with the hyperlink": function() { + var authorInstrText = new XmlElement("w:instrText", {}, [ + xml.text(' AUTHOR "John Doe"') + ]); + var paragraphXml = new XmlElement("w:p", {}, [ + beginXml, + hyperlinkInstrText, + separateXml, + hyperlinkRunXml, + beginXml, + authorInstrText, + endXml, + endXml + ]); + var paragraph = readXmlElementValue(paragraphXml); + + assertThat(paragraph.children, contains( + isEmptyRun, + isRun({ + children: contains( + isHyperlink({ + href: uri, + children: [] + }) + ) + }), + isRun({ + children: contains( + isHyperlink({ + href: uri, + children: contains( + isText("this is a hyperlink") + ) + }) + ) + }), + isRun({ + children: contains( + isHyperlink({ + href: uri, + children: [] + }) + ) + }), + isEmptyRun, + isEmptyRun + )); } }; })()); -- cgit v1.2.3