aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-08-16 20:30:02 +0200
committerKim Alvefur <zash@zash.se>2020-08-16 20:30:02 +0200
commit8de93db692033a56ab3a516c9aadf6b27060e2a7 (patch)
treeb231d993ff5689de91c3776086784ecf3144a2ed /spec
parent1c0e4300ab36e37cb2ba83e5dca9f9247785bed6 (diff)
downloadprosody-8de93db692033a56ab3a516c9aadf6b27060e2a7.tar.gz
prosody-8de93db692033a56ab3a516c9aadf6b27060e2a7.zip
util.dataforms: Add more XEP-0211 media element test coverage
Diffstat (limited to 'spec')
-rw-r--r--spec/util_dataforms_spec.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/util_dataforms_spec.lua b/spec/util_dataforms_spec.lua
index ae6098be..0df9fb1d 100644
--- a/spec/util_dataforms_spec.lua
+++ b/spec/util_dataforms_spec.lua
@@ -438,5 +438,33 @@ describe("util.dataforms", function ()
assert.string(e.number);
end);
end);
+ describe("media element", function ()
+ it("produced media element correctly", function ()
+ local f;
+ for field in xform:childtags("field") do
+ if field.attr.var == "text-single-with-media-field" then
+ f = field;
+ break;
+ end
+ end
+
+ assert.truthy(st.is_stanza(f));
+ assert.equal("text-single-with-media-field", f.attr.var);
+ assert.equal("text-single", f.attr.type);
+ assert.equal("text-single-with-media-label", f.attr.label);
+ assert.equal(0, iter.count(f:childtags("value")));
+
+ local m = f:get_child("media", "urn:xmpp:media-element");
+ assert.truthy(st.is_stanza(m));
+ assert.equal("24", m.attr.height);
+ assert.equal("32", m.attr.width);
+ assert.equal(1, iter.count(m:childtags("uri")));
+
+ local u = m:get_child("uri");
+ assert.truthy(st.is_stanza(u));
+ assert.equal("image/png", u.attr.type);
+ assert.equal("data:", u:get_text());
+ end);
+ end);
end);