Diff

spec/util_dataforms_spec.lua @ 9242:68694c1bd960

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.
author Kim Alvefur <zash@zash.se>
date Sat, 01 Sep 2018 01:24:46 +0200
parent 9121:e5eb36ee07a2
child 9243:a4c52e304e6f
line wrap: on
line diff
--- a/spec/util_dataforms_spec.lua	Mon Sep 03 17:45:30 2018 +0100
+++ b/spec/util_dataforms_spec.lua	Sat Sep 01 01:24:46 2018 +0200
@@ -386,5 +386,20 @@
 			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);