Changeset

11027:8ed6c5bdbb21

util.dataforms: Add more XEP-0211 media element test coverage
author Kim Alvefur <zash@zash.se>
date Sun, 16 Aug 2020 20:30:02 +0200
parents 11026:a086825ed73a
children 11028:d7a403060946
files spec/util_dataforms_spec.lua
diffstat 1 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/spec/util_dataforms_spec.lua	Sun Aug 16 12:55:55 2020 +0200
+++ b/spec/util_dataforms_spec.lua	Sun Aug 16 20:30:02 2020 +0200
@@ -438,5 +438,33 @@
 			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);