summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-09-09 09:17:22 +0100
committerMichael Williamson <mike@zwobble.org>2025-09-09 09:17:22 +0100
commit5ec3c49c22c3448cd0583be74512129c221cd030 (patch)
tree5066884e2841458c63f8e811e96430db19d8a5ee /test
parent033466fcb57ba2f4c0f876ed8dec705de5c68333 (diff)
Test reading of table rows when non-rows are present
Diffstat (limited to 'test')
-rw-r--r--test/docx/body-reader.tests.js38
1 files changed, 37 insertions, 1 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js
index c60ef0d..f6c986f 100644
--- a/test/docx/body-reader.tests.js
+++ b/test/docx/body-reader.tests.js
@@ -1305,10 +1305,46 @@ test("when row is marked as deleted in row properties then row is ignored", func
});
test("warning if non-row in table", function() {
+ // Include normal rows to ensure they're still read correctly.
var tableXml = new XmlElement("w:tbl", {}, [
- new XmlElement("w:p")
+ xml.element("w:tr", {}, [
+ xml.element("w:tc", {}, [
+ xml.element("w:p", {}, [
+ runOfText("Row 1")
+ ])
+ ])
+ ]),
+ new XmlElement("w:p"),
+ xml.element("w:tr", {}, [
+ xml.element("w:tc", {}, [
+ xml.element("w:p", {}, [
+ runOfText("Row 2")
+ ])
+ ])
+ ])
]);
var result = readXmlElement(tableXml);
+ assert.deepEqual(result.value, new documents.Table([
+ new documents.TableRow([
+ new documents.TableCell([
+ new documents.Paragraph([
+ new documents.Run([
+ new documents.Text("Row 1")
+ ])
+ ])
+ ])
+ ]),
+ new documents.Paragraph([]),
+ new documents.TableRow([
+ new documents.TableCell([
+ new documents.Paragraph([
+ new documents.Run([
+ new documents.Text("Row 2")
+ ])
+ ])
+ ])
+ ])
+ ]));
assert.deepEqual(result.messages, [warning("unexpected non-row element in table, cell merging may be incorrect")]);
});