diff options
| author | Jonathan Lehman <jonathan.lehman91@gmail.com> | 2017-02-17 12:35:26 -0500 |
|---|---|---|
| committer | Jonathan Lehman <jonathan.lehman91@gmail.com> | 2017-02-17 12:35:26 -0500 |
| commit | c044f44f404bb4e38d38082d2989c5686604bb3e (patch) | |
| tree | 3bd786e0bbdbcca1448fedd3ea6922d072e3cb3f /test | |
| parent | 75e327ddfff69d7bdbaff994e4662f7c37cc2b85 (diff) | |
Handle nested complex fields
Diffstat (limited to 'test')
| -rw-r--r-- | test/docx/body-reader.tests.js | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index 4cb7bb3..1882f3a 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -154,6 +154,7 @@ test("complex fields", (function() { var hyperlinkInstrText = new XmlElement("w:instrText", {}, [ xml.text(' HYPERLINK "' + uri + '"') ]); + var hyperlinkRunXml = runOfText("this is a hyperlink"); return { "stores instrText returns empty result": function() { @@ -227,7 +228,6 @@ test("complex fields", (function() { }, "can handle split instrText elements": function() { - var hyperlinkRunXml = runOfText("this is a hyperlink"); var hyperlinkInstrTextPart1 = new XmlElement("w:instrText", {}, [ xml.text(" HYPE") ]); @@ -266,6 +266,48 @@ test("complex fields", (function() { }), isEmptyRun )); + }, + + "hyperlink with a nested complex field uses the outer hyperlink": function() { + var authorInstrText = new XmlElement("w:instrText", {}, [ + xml.text(' AUTHOR "John Doe"') + ]); + var paragraphXml = new XmlElement("w:p", {}, [ + beginXml, + beginXml, + authorInstrText, + endXml, + hyperlinkInstrText, + separateXml, + hyperlinkRunXml, + endXml + ]); + var paragraph = readXmlElementValue(paragraphXml); + + assertThat(paragraph.children, contains( + isEmptyRun, + isEmptyRun, + isEmptyRun, + isRun({ + children: contains( + isHyperlink({ + href: uri, + children: [] + }) + ) + }), + isRun({ + children: contains( + isHyperlink({ + href: uri, + children: contains( + isText("this is a hyperlink") + ) + }) + ) + }), + isEmptyRun + )); } }; })()); |
