Comparison

spec/util_dataforms_spec.lua @ 11874:84f4c6957d62

util.dataforms: Add support for datetime field types via XEP-0122
author Kim Alvefur <zash@zash.se>
date Mon, 25 Oct 2021 21:45:46 +0200
parent 11070:f7f30a3464fe
child 11877:593b141ba01c
comparison
equal deleted inserted replaced
11873:2b85e4e7d389 11874:84f4c6957d62
444 local d,e = f:data(f:form({number = 100})); 444 local d,e = f:data(f:form({number = 100}));
445 assert.not_equal(100, d.number); 445 assert.not_equal(100, d.number);
446 assert.table(e); 446 assert.table(e);
447 assert.string(e.number); 447 assert.string(e.number);
448 end); 448 end);
449
450 describe("datetime", function ()
451 local f = dataforms.new { { name = "when"; type = "text-single"; datatype = "xs:dateTime" } } -- luacheck: ignore 431
452
453 it("works", function ()
454 local x = f:form({ when = "2008-08-22T21:09:00Z" });
455 assert.equal("2008-08-22T21:09:00Z", x:find("field/value#"))
456 local d, e = f:data(x);
457 assert.is_nil(e);
458 assert.same({ when = 1219439340 }, d);
459 end);
460
461 end)
462
449 end); 463 end);
450 describe("media element", function () 464 describe("media element", function ()
451 it("produced media element correctly", function () 465 it("produced media element correctly", function ()
452 local f; 466 local f;
453 for field in xform:childtags("field") do 467 for field in xform:childtags("field") do