From 00a28917877a2b5ac762e8720b11a1f532802dc8 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 30 Jun 2018 20:49:26 +0200 Subject: util.dataforms: Add failing test for #1177 --- spec/util_dataforms_spec.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'spec') diff --git a/spec/util_dataforms_spec.lua b/spec/util_dataforms_spec.lua index f4c0d8b5..66236e96 100644 --- a/spec/util_dataforms_spec.lua +++ b/spec/util_dataforms_spec.lua @@ -320,5 +320,32 @@ describe("util.dataforms", function () 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); -- cgit v1.2.3