Diff

spec/util_datamapper_spec.lua @ 11468:348b191cd850

util.datamapper: Complete array building support
author Kim Alvefur <zash@zash.se>
date Sat, 20 Mar 2021 21:29:51 +0100
parent 11466:c098d07e6717
child 11476:83e127eb91f9
line wrap: on
line diff
--- a/spec/util_datamapper_spec.lua	Sat Mar 20 21:25:45 2021 +0100
+++ b/spec/util_datamapper_spec.lua	Sat Mar 20 21:29:51 2021 +0100
@@ -181,5 +181,16 @@
 			assert.equal(#x.tags-1, #u.tags)
 
 		end);
+
+		it("handles arrays", function ()
+			local u = map.unparse(disco_schema, disco);
+			assert.equal("urn:example:feature:1", u:find("{http://jabber.org/protocol/disco#info}query/feature/@var"))
+			local n = 0;
+			for child in u:get_child("query", "http://jabber.org/protocol/disco#info"):childtags("feature") do
+				n = n + 1;
+				assert.equal(string.format("urn:example:feature:%d", n), child.attr.var);
+			end
+		end);
+
 	end);
 end)