aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_dataforms_spec.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-08-06 08:21:55 +0100
committerMatthew Wild <mwild1@gmail.com>2018-08-06 08:21:55 +0100
commit96509275b883522d8a16bed56c998a2a2fe0424f (patch)
tree8a905f8eee3e7772c11f811003d310094f78d6a2 /spec/util_dataforms_spec.lua
parent56b0cd35c6768193b5c237c176339f176b73f1a2 (diff)
parent27bbd90669cf314d6945892456e4ed0a20590302 (diff)
downloadprosody-96509275b883522d8a16bed56c998a2a2fe0424f.tar.gz
prosody-96509275b883522d8a16bed56c998a2a2fe0424f.zip
Merge with jonasw
Diffstat (limited to 'spec/util_dataforms_spec.lua')
-rw-r--r--spec/util_dataforms_spec.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/util_dataforms_spec.lua b/spec/util_dataforms_spec.lua
index 66236e96..863a3290 100644
--- a/spec/util_dataforms_spec.lua
+++ b/spec/util_dataforms_spec.lua
@@ -347,5 +347,44 @@ describe("util.dataforms", function ()
assert.truthy(f:find("field/option"));
end);
end);
+
+ describe("using current values in place of missing fields", function ()
+ it("gets back the previous values when given an empty form", function ()
+ local current = {
+ ["list-multi-field"] = {
+ "list-multi-option-value#2";
+ };
+ ["list-single-field"] = "list-single-value#2";
+ ["hidden-field"] = "hidden-value";
+ ["boolean-field"] = false;
+ ["text-multi-field"] = "words\ngo\nhere";
+ ["jid-single-field"] = "alice@example.com";
+ ["text-private-field"] = "hunter2";
+ ["text-single-field"] = "text-single-value";
+ ["jid-multi-field"] = {
+ "bob@example.net";
+ };
+ };
+ local expect = {
+ -- FORM_TYPE = "xmpp:prosody.im/spec/util.dataforms#1"; -- does this need to be included?
+ ["list-multi-field"] = {
+ "list-multi-option-value#2";
+ };
+ ["list-single-field"] = "list-single-value#2";
+ ["hidden-field"] = "hidden-value";
+ ["boolean-field"] = false;
+ ["text-multi-field"] = "words\ngo\nhere";
+ ["jid-single-field"] = "alice@example.com";
+ ["text-private-field"] = "hunter2";
+ ["text-single-field"] = "text-single-value";
+ ["jid-multi-field"] = {
+ "bob@example.net";
+ };
+ };
+ local data, err = some_form:data(st.stanza("x", {xmlns="jabber:x:data"}), current);
+ assert.is.table(data, err);
+ assert.same(expect, data, "got back the same data");
+ end);
+ end);
end);