diff options
| author | Michael Williamson <mike@zwobble.org> | 2025-05-28 19:53:26 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2025-05-28 19:53:26 +0100 |
| commit | 5896154e69430a67a758864576c5eda8796f152a (patch) | |
| tree | 111472a1940ad0dd6e43b4347624ad7bfc535a10 /test | |
| parent | a193c98872cc8dcd800dd10af17a6fddd4897e4f (diff) | |
Ignore AlternateContent elements when there is no Fallback element
Diffstat (limited to 'test')
| -rw-r--r-- | test/docx/body-reader.tests.js | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index 96f4922..8f36998 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -1630,18 +1630,30 @@ test("text boxes have content appended after containing paragraph", function() { assert.deepEqual(result.value[1].styleId, "textbox-content"); }); -test("mc:Fallback is used when mc:AlternateContent is read", function() { - var styles = new Styles({"first": {name: "First"}, "second": {name: "Second"}}, {}); - var textbox = new XmlElement("mc:AlternateContent", {}, [ - new XmlElement("mc:Choice", {"Requires": "wps"}, [ - paragraphWithStyleId("first") - ]), - new XmlElement("mc:Fallback", {}, [ - paragraphWithStyleId("second") - ]) - ]); - var result = readXmlElement(textbox, {styles: styles}); - assert.deepEqual(result.value[0].styleId, "second"); +test("mc:AlternateContent", { + "when mc:Fallback is present then mc:Fallback is read": function() { + var styles = new Styles({"first": {name: "First"}, "second": {name: "Second"}}, {}); + var textbox = new XmlElement("mc:AlternateContent", {}, [ + new XmlElement("mc:Choice", {"Requires": "wps"}, [ + paragraphWithStyleId("first") + ]), + new XmlElement("mc:Fallback", {}, [ + paragraphWithStyleId("second") + ]) + ]); + var result = readXmlElement(textbox, {styles: styles}); + assert.deepEqual(result.value[0].styleId, "second"); + }, + + "when mc:Fallback is not present then element is ignored": function() { + var textbox = new XmlElement("mc:AlternateContent", {}, [ + new XmlElement("mc:Choice", {"Requires": "wps"}, [ + paragraphWithStyleId("first") + ]) + ]); + var result = readXmlElement(textbox); + assert.deepEqual(result.value, []); + } }); test("w:sdtContent is used when w:sdt is read", function() { |
