diff options
| author | Michael Williamson <mike@zwobble.org> | 2025-09-09 09:19:21 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2025-09-09 09:19:21 +0100 |
| commit | 8ca702caace290b532b8e83b44900ff24aca17ff (patch) | |
| tree | e183552e1d3eddfa64a7cc757f0fc9b74e3c49b3 /test | |
| parent | 5ec3c49c22c3448cd0583be74512129c221cd030 (diff) | |
Test reading of table cells when non-cells are present
Diffstat (limited to 'test')
| -rw-r--r-- | test/docx/body-reader.tests.js | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index f6c986f..4fbea03 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -1323,7 +1323,9 @@ test("warning if non-row in table", function() { ]) ]) ]); + var result = readXmlElement(tableXml); + assert.deepEqual(result.value, new documents.Table([ new documents.TableRow([ new documents.TableCell([ @@ -1349,10 +1351,44 @@ test("warning if non-row in table", function() { }); test("warning if non-cell in table row", function() { + // Include normal cells to ensure they're still read correctly. var tableXml = new XmlElement("w:tbl", {}, [ - row(new XmlElement("w:p")) + row( + xml.element("w:tc", {}, [ + xml.element("w:p", {}, [ + runOfText("Cell 1") + ]) + ]), + new XmlElement("w:p"), + xml.element("w:tc", {}, [ + xml.element("w:p", {}, [ + runOfText("Cell 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("Cell 1") + ]) + ]) + ]), + new documents.Paragraph([]), + new documents.TableCell([ + new documents.Paragraph([ + new documents.Run([ + new documents.Text("Cell 2") + ]) + ]) + ]) + ]) + ])); assert.deepEqual(result.messages, [warning("unexpected non-cell element in table row, cell merging may be incorrect")]); }); |
