File

spec/util_xml_spec.lua @ 11786:39164ea2ab9e

util.stanza: Add :get_child_with_attr() + tests
author Matthew Wild <mwild1@gmail.com>
date Sun, 12 Sep 2021 10:31:02 +0100
parent 8236:4878e4159e12
child 12180:53e0ae770917
line wrap: on
line source


local xml = require "util.xml";

describe("util.xml", function()
	describe("#parse()", function()
		it("should work", function()
			local x =
[[<x xmlns:a="b">
	<y xmlns:a="c"> <!-- this overwrites 'a' -->
	    <a:z/>
	</y>
	<a:z/> <!-- prefix 'a' is nil here, but should be 'b' -->
</x>
]]
			local stanza = xml.parse(x);
			assert.are.equal(stanza.tags[2].attr.xmlns, "b");
			assert.are.equal(stanza.tags[2].namespaces["a"], "b");
		end);
	end);
end);