From ae06a2bacfb74c88340e900e8a29336418936e9e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 5 Dec 2026 10:19:25 +0000 Subject: Handle XML documents that are missing a root element --- test/xml/reader.tests.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'test/xml/reader.tests.js') diff --git a/test/xml/reader.tests.js b/test/xml/reader.tests.js index 6b7d3a0..3515835 100644 --- a/test/xml/reader.tests.js +++ b/test/xml/reader.tests.js @@ -46,7 +46,7 @@ test('mapped namespaces URIs are translated using map', function() { var namespaceMap = { "word": "x" }; - + return xmlreader.readString('', namespaceMap).then(function(result) { assert.deepEqual(result.name, "x:body"); }); @@ -83,3 +83,11 @@ test('error if XML is badly formed', function() { return 1; }); }); + +test("when document is missing root element then null is returned", function() { + var xmlString = ''; + + return xmlreader.readString(xmlString).then(function(element) { + assert.strictEqual(element, null); + }); +}); -- cgit v1.2.3