Software /
code /
prosody
Diff
spec/util_dataforms_spec.lua @ 9083:5d3639e415bd
util.dataforms: Add failing test for #1177
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 30 Jun 2018 20:49:26 +0200 |
parent | 9046:7cdc718312c8 |
child | 9121:e5eb36ee07a2 |
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);