aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_datamapper_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-03-07 00:57:36 +0100
committerKim Alvefur <zash@zash.se>2021-03-07 00:57:36 +0100
commitd8e9e044f2be19a01af4c3c9a0ac99b8d00fdcba (patch)
tree56e4f8a1bc39a685da57512c78ef46614d8b7bf3 /spec/util_datamapper_spec.lua
parent081eb23c54b685c01e531468e6ba59740d779878 (diff)
downloadprosody-d8e9e044f2be19a01af4c3c9a0ac99b8d00fdcba.tar.gz
prosody-d8e9e044f2be19a01af4c3c9a0ac99b8d00fdcba.zip
util.datamapper: Add 'unparse' for turning tables into XML
Diffstat (limited to 'spec/util_datamapper_spec.lua')
-rw-r--r--spec/util_datamapper_spec.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/util_datamapper_spec.lua b/spec/util_datamapper_spec.lua
index 0e1dfdab..2ef828f2 100644
--- a/spec/util_datamapper_spec.lua
+++ b/spec/util_datamapper_spec.lua
@@ -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)