Changeset

9083:5d3639e415bd

util.dataforms: Add failing test for #1177
author Kim Alvefur <zash@zash.se>
date Sat, 30 Jun 2018 20:49:26 +0200 (2018-06-30)
parents 9082:297a06074175
children 9084:572b6858db03
files spec/util_dataforms_spec.lua
diffstat 1 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/spec/util_dataforms_spec.lua	Fri Aug 03 20:39:18 2018 +0200
+++ b/spec/util_dataforms_spec.lua	Sat Jun 30 20:49:26 2018 +0200
@@ -320,5 +320,32 @@
 			assert.truthy(some_form:data(xform));
 		end);
 	end);
+
+	describe("issue1177", function ()
+		local form_with_stuff;
+		setup(function ()
+			form_with_stuff = dataforms.new({
+				{
+					type = "list-single";
+					name = "abtest";
+					label = "A or B?";
+					options = {
+						{ label = "A", value = "a", default = true },
+						{ label = "B", value = "b" },
+					};
+				},
+			});
+		end);
+
+		it("includes options when value is included", function ()
+			local f = form_with_stuff:form({ abtest = "a" });
+			assert.truthy(f:find("field/option"));
+		end);
+
+		it("includes options when value is excluded", function ()
+			local f = form_with_stuff:form({});
+			assert.truthy(f:find("field/option"));
+		end);
+	end);
 end);