diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-02-18 10:51:56 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-02-18 10:51:56 +0000 |
| commit | 0459e2cf53ad8670e6692020f5864eafffe2caf9 (patch) | |
| tree | 696066f4fe3b9f66abcc29386d9be73ac0c31c5d /test | |
| parent | 7194953e90ab7a24b49f471b23cc30d03beba517 (diff) | |
Improve error message when failing to find the body element in a document
Diffstat (limited to 'test')
| -rw-r--r-- | test/docx/document-xml-reader.tests.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/docx/document-xml-reader.tests.js b/test/docx/document-xml-reader.tests.js index 08389e1..10c8df1 100644 --- a/test/docx/document-xml-reader.tests.js +++ b/test/docx/document-xml-reader.tests.js @@ -23,3 +23,17 @@ test("when body element is present then body is read", function() { {} )); }); + +test("when body element is not present then error is thrown", function() { + var bodyReader = createBodyReaderForTests({}); + var documentXmlReader = new DocumentXmlReader({ + bodyReader: bodyReader + }); + var paragraphXml = xml.element("w:p", {}, []); + var bodyXml = xml.element("w:body2", {}, [paragraphXml]); + var documentXml = xml.element("w:document", {}, [bodyXml]); + + assert.throws(function() { + documentXmlReader.convertXmlToDocument(documentXml); + }, /Could not find the body element: are you sure this is a docx file?/); +}); |
