From a7448e43e0daa2772511d7744727f91db4962346 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 2 Jun 2018 19:57:46 +0200 Subject: util.dataforms: Add a simple function for identifying form types This is meant to allow identifying forms without parsing them completely. --- spec/util_dataforms_spec.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'spec') diff --git a/spec/util_dataforms_spec.lua b/spec/util_dataforms_spec.lua index 4b85444f..56751041 100644 --- a/spec/util_dataforms_spec.lua +++ b/spec/util_dataforms_spec.lua @@ -301,5 +301,14 @@ describe("util.dataforms", function () 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); -- cgit v1.2.3