Comparison

spec/util_dataforms_spec.lua @ 11878:bf6706057283

util.dataforms: Turn number values into timestamps for datetime fields Makes it symmetric with parsing.
author Kim Alvefur <zash@zash.se>
date Tue, 26 Oct 2021 15:17:49 +0200
parent 11877:593b141ba01c
child 11879:b8b889ba8d27
comparison
equal deleted inserted replaced
11877:593b141ba01c 11878:bf6706057283
459 459
460 describe("datetime", function () 460 describe("datetime", function ()
461 local f = dataforms.new { { name = "when"; type = "text-single"; datatype = "xs:dateTime" } } -- luacheck: ignore 431 461 local f = dataforms.new { { name = "when"; type = "text-single"; datatype = "xs:dateTime" } } -- luacheck: ignore 431
462 462
463 it("works", function () 463 it("works", function ()
464 local x = f:form({ when = "2008-08-22T21:09:00Z" }); 464 local x = f:form({ when = 1219439340 });
465 assert.equal("2008-08-22T21:09:00Z", x:find("field/value#")) 465 assert.equal("2008-08-22T21:09:00Z", x:find("field/value#"))
466 local d, e = f:data(x); 466 local d, e = f:data(x);
467 assert.is_nil(e); 467 assert.is_nil(e);
468 assert.same({ when = 1219439340 }, d); 468 assert.same({ when = 1219439340 }, d);
469 end); 469 end);