util.datamapper: Add 'unparse' for turning tables into XML

This commit is contained in:
Kim Alvefur 2021-03-07 00:57:36 +01:00
parent 081eb23c54
commit d8e9e044f2
3 changed files with 216 additions and 2 deletions

View file

@ -53,4 +53,16 @@ describe("util.datampper", function()
assert.same(d, map.parse(s, x));
end);
end);
describe("unparse", function()
it("works", function()
local u = map.unparse(s, d);
assert.equal("message", u.name);
assert.same(x.attr, u.attr);
assert.equal(#x.tags, #u.tags)
assert.equal(x:get_child_text("body"), u:get_child_text("body"));
assert.equal(x:get_child_text("delay", "urn:xmpp:delay"), u:get_child_text("delay", "urn:xmpp:delay"));
assert.same(x:get_child("delay", "urn:xmpp:delay").attr, u:get_child("delay", "urn:xmpp:delay").attr);
end);
end);
end)