From 500e1c20fe77c7ebd561e9f7d8c2b494ebdfced2 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 30 Nov 2024 11:36:24 +0000 Subject: Parse checked value of complex field checkbox --- test/docx/body-reader.tests.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'test') diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index 49c81b9..70b0057 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -579,6 +579,48 @@ test("checkboxes", { var paragraph = readXmlElementValue(paragraphXml); + assertThat(paragraph.children, contains( + isEmptyRun, + isEmptyRun, + isRun({ + children: contains( + isCheckbox({checked: equalTo(true)}) + ) + }) + )); + }, + + "complex field checkbox with w:default=1 and w:checked=0 is unchecked": function() { + var paragraphXml = complexFieldCheckboxParagraph([ + xml.element("w:checkBox", {}, [ + xml.element("w:default", {"w:val": "1"}), + xml.element("w:checked", {"w:val": "0"}) + ]) + ]); + + var paragraph = readXmlElementValue(paragraphXml); + + assertThat(paragraph.children, contains( + isEmptyRun, + isEmptyRun, + isRun({ + children: contains( + isCheckbox({checked: equalTo(false)}) + ) + }) + )); + }, + + "complex field checkbox with w:default=0 and w:checked=1 is checked": function() { + var paragraphXml = complexFieldCheckboxParagraph([ + xml.element("w:checkBox", {}, [ + xml.element("w:default", {"w:val": "0"}), + xml.element("w:checked", {"w:val": "1"}) + ]) + ]); + + var paragraph = readXmlElementValue(paragraphXml); + assertThat(paragraph.children, contains( isEmptyRun, isEmptyRun, -- cgit v1.2.3