diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-11-30 11:54:54 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-11-30 11:54:54 +0000 |
| commit | 888a3bd67f658e8a3894eb5e2ece3c14cd2e9179 (patch) | |
| tree | 3a0a1ee2a2f6a3d8fc37cc58740d0d82f28e7461 /test | |
| parent | ce471de77aa93bd2f6516c12f0b8e989382acf86 (diff) | |
Handle complex field checkboxes without separate field char
Diffstat (limited to 'test')
| -rw-r--r-- | test/docx/body-reader.tests.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index 70b0057..ece3af8 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -532,6 +532,60 @@ test("complex fields", (function() { })()); test("checkboxes", { + "complex field checkbox without separate is read": function() { + var paragraphXml = xml.element("w:p", {}, [ + xml.element("w:r", {}, [ + xml.element("w:fldChar", {"w:fldCharType": "begin"}) + ]), + xml.element("w:instrText", {}, [ + xml.text(' FORMCHECKBOX ') + ]), + xml.element("w:r", {}, [ + xml.element("w:fldChar", {"w:fldCharType": "end"}) + ]) + ]); + + var paragraph = readXmlElementValue(paragraphXml); + + assertThat(paragraph.children, contains( + isEmptyRun, + isRun({ + children: contains( + isCheckbox() + ) + }) + )); + }, + + "complex field checkbox with separate is read": function() { + var paragraphXml = xml.element("w:p", {}, [ + xml.element("w:r", {}, [ + xml.element("w:fldChar", {"w:fldCharType": "begin"}) + ]), + xml.element("w:instrText", {}, [ + xml.text(' FORMCHECKBOX ') + ]), + xml.element("w:r", {}, [ + xml.element("w:fldChar", {"w:fldCharType": "separate"}) + ]), + xml.element("w:r", {}, [ + xml.element("w:fldChar", {"w:fldCharType": "end"}) + ]) + ]); + + var paragraph = readXmlElementValue(paragraphXml); + + assertThat(paragraph.children, contains( + isEmptyRun, + isEmptyRun, + isRun({ + children: contains( + isCheckbox() + ) + }) + )); + }, + "complex field checkbox without w:default nor w:checked is unchecked": function() { var paragraphXml = complexFieldCheckboxParagraph([ xml.element("w:checkBox") |
