# HG changeset patch # User Kim Alvefur # Date 1530384566 -7200 # Node ID 5d3639e415bd5c0da4dcf29965a381b47ed5e7a5 # Parent 297a0607417583584348b5f7503da7da5eddbf32 util.dataforms: Add failing test for #1177 diff -r 297a06074175 -r 5d3639e415bd spec/util_dataforms_spec.lua --- 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);