Diff

spec/util_dataforms_spec.lua @ 8864:cf2f66b233d1

util.dataforms: Add a simple function for identifying form types This is meant to allow identifying forms without parsing them completely.
author Kim Alvefur <zash@zash.se>
date Sat, 02 Jun 2018 19:57:46 +0200
parent 8862:900dff5ef498
child 9046:7cdc718312c8
line wrap: on
line diff
--- a/spec/util_dataforms_spec.lua	Sat Jun 02 19:49:15 2018 +0200
+++ b/spec/util_dataforms_spec.lua	Sat Jun 02 19:57:46 2018 +0200
@@ -301,5 +301,14 @@
 		assert.equal("text-single-value", f:get_child_text("value"));
 	end);
 
+	describe("get_type()", function ()
+		it("identifes dataforms", function ()
+			assert.equal(nil, dataforms.get_type(nil));
+			assert.equal(nil, dataforms.get_type(""));
+			assert.equal(nil, dataforms.get_type({}));
+			assert.equal(nil, dataforms.get_type(st.stanza("no-a-form")));
+			assert.equal("xmpp:prosody.im/spec/util.dataforms#1", dataforms.get_type(xform));
+		end);
+	end);
 end);