aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_datamapper_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-03-19 01:17:59 +0100
committerKim Alvefur <zash@zash.se>2021-03-19 01:17:59 +0100
commit7f04df223a369d7d3bb92cf94d0ad64ad5fb6ac9 (patch)
treeae9544ebae148df5f9159b03df6f913ebaa4efb6 /spec/util_datamapper_spec.lua
parent3c3cdcd0c7a6895b90d03480bbc9fba69b74008f (diff)
downloadprosody-7f04df223a369d7d3bb92cf94d0ad64ad5fb6ac9.tar.gz
prosody-7f04df223a369d7d3bb92cf94d0ad64ad5fb6ac9.zip
util.datamapper: Fix arrays nesting one level too deep
Diffstat (limited to 'spec/util_datamapper_spec.lua')
-rw-r--r--spec/util_datamapper_spec.lua22
1 files changed, 15 insertions, 7 deletions
diff --git a/spec/util_datamapper_spec.lua b/spec/util_datamapper_spec.lua
index ee4d3c16..6d75facf 100644
--- a/spec/util_datamapper_spec.lua
+++ b/spec/util_datamapper_spec.lua
@@ -46,10 +46,13 @@ describe("util.datampper", function()
type = "string";
xml = {name = "origin-id"; namespace = "urn:xmpp:sid:0"; x_single_attribute = "id"};
};
- reactions = {
- type = "array";
- xml = {namespace = "urn:xmpp:reactions:0"; wrapped = true};
- items = {type = "string"; xml = {name = "reaction"}};
+ react = {
+ type = "object";
+ xml = {namespace = "urn:xmpp:reactions:0"; name = "reactions"};
+ properties = {
+ to = {type = "string"; xml = {attribute = true; name = "id"}};
+ reactions = {type = "array"; items = {type = "string"; xml = {name = "reaction"}}};
+ };
};
};
};
@@ -80,9 +83,12 @@ describe("util.datampper", function()
state = "active";
fallback = true;
origin_id = "qgkmMdPB";
- reactions = {
- "👋",
- "🐢",
+ react = {
+ to = "744f6e18-a57a-11e9-a656-4889e7820c76";
+ reactions = {
+ "👋",
+ "🐢",
+ };
};
};
end);
@@ -102,6 +108,8 @@ describe("util.datampper", function()
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);
assert.same(x:get_child("origin-id", "urn:xmpp:sid:0").attr, u:get_child("origin-id", "urn:xmpp:sid:0").attr);
+ assert.same(x:get_child("reactions", "urn:xmpp:reactions:0").attr, u:get_child("reactions", "urn:xmpp:reactions:0").attr);
+ assert.same(2, #u:get_child("reactions", "urn:xmpp:reactions:0").tags);
for _, tag in ipairs(x.tags) do
if tag.name ~= "UNRELATED" then
assert.truthy(u:get_child(tag.name, tag.attr.xmlns) or u:get_child(tag.name), tag:top_tag())