aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_dataforms_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-09-01 01:24:46 +0200
committerKim Alvefur <zash@zash.se>2018-09-01 01:24:46 +0200
commit3da47d7dde637947a736debd4c350bd7eaaa8198 (patch)
tree044e31819102a37413083044bffde12de008df5c /spec/util_dataforms_spec.lua
parentc9cc5d4a6e469464596b18326bfeade3e48dc868 (diff)
downloadprosody-3da47d7dde637947a736debd4c350bd7eaaa8198.tar.gz
prosody-3da47d7dde637947a736debd4c350bd7eaaa8198.zip
util.dataforms: Allow field names to be different from the 'var' attribute
This should allow the usage of long prefixes and namespace-like names to be contained to the XML representation of the form, so that the code can use more convenient names.
Diffstat (limited to 'spec/util_dataforms_spec.lua')
-rw-r--r--spec/util_dataforms_spec.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/util_dataforms_spec.lua b/spec/util_dataforms_spec.lua
index 863a3290..123b9f8a 100644
--- a/spec/util_dataforms_spec.lua
+++ b/spec/util_dataforms_spec.lua
@@ -386,5 +386,20 @@ describe("util.dataforms", function ()
assert.same(expect, data, "got back the same data");
end);
end);
+
+ describe("field 'var' property", function ()
+ it("works as expected", function ()
+ local f = dataforms.new {
+ {
+ var = "someprefix#the-field",
+ name = "the_field",
+ type = "text-single",
+ }
+ };
+ local x = f:form({the_field = "hello"});
+ assert.equal("someprefix#the-field", x:find"field@var");
+ assert.equal("hello", x:find"field/value#");
+ end);
+ end);
end);