Software /
code /
prosody
Diff
spec/util_datamapper_spec.lua @ 11436:5df9ffc25bb4
util.datamapper: Add 'unparse' for turning tables into XML
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 07 Mar 2021 00:57:36 +0100 |
parent | 11435:a1fa6202fa13 |
child | 11437:87a684df4b65 |
line wrap: on
line diff
--- a/spec/util_datamapper_spec.lua Sun Mar 07 00:57:36 2021 +0100 +++ b/spec/util_datamapper_spec.lua Sun Mar 07 00:57:36 2021 +0100 @@ -53,4 +53,16 @@ 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)