# HG changeset patch # User Kim Alvefur # Date 1635255714 -7200 # Node ID b8b889ba8d2746fdb8be8ca86c2b92fbe66225a2 # Parent bf67060572839f0b488ed0917c8b688639d5c79f util.dataforms: Scope integer handling tests So they're separate from the datetime tests, and any future validation tests diff -r bf6706057283 -r b8b889ba8d27 spec/util_dataforms_spec.lua --- a/spec/util_dataforms_spec.lua Tue Oct 26 15:17:49 2021 +0200 +++ b/spec/util_dataforms_spec.lua Tue Oct 26 15:41:54 2021 +0200 @@ -428,37 +428,40 @@ end) describe("datatype validation", function () - local f = dataforms.new { - { - name = "number", - type = "text-single", - datatype = "xs:integer", - range_min = -10, - range_max = 10, - }, - }; + describe("integer", function () + + local f = dataforms.new { + { + name = "number", + type = "text-single", + datatype = "xs:integer", + range_min = -10, + range_max = 10, + }, + }; - it("integer roundtrip works", function () - local d = f:data(f:form({number = 1})); - assert.equal(1, d.number); - end); + it("roundtrip works", function () + local d = f:data(f:form({number = 1})); + assert.equal(1, d.number); + end); - it("integer error handling works", function () - local d,e = f:data(f:form({number = "nan"})); - assert.not_equal(1, d.number); - assert.table(e); - assert.string(e.number); - end); + it("error handling works", function () + local d,e = f:data(f:form({number = "nan"})); + assert.not_equal(1, d.number); + assert.table(e); + assert.string(e.number); + end); - it("works", function () - local d,e = f:data(f:form({number = 100})); - assert.not_equal(100, d.number); - assert.table(e); - assert.string(e.number); - end); + it("bounds-cheking work works", function () + local d,e = f:data(f:form({number = 100})); + assert.not_equal(100, d.number); + assert.table(e); + assert.string(e.number); + end); + end) describe("datetime", function () - local f = dataforms.new { { name = "when"; type = "text-single"; datatype = "xs:dateTime" } } -- luacheck: ignore 431 + local f = dataforms.new { { name = "when"; type = "text-single"; datatype = "xs:dateTime" } } it("works", function () local x = f:form({ when = 1219439340 });