Software / code / prosody
Diff
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 |
line wrap: on
line diff
--- a/spec/util_dataforms_spec.lua Mon Oct 25 21:45:06 2021 +0200 +++ b/spec/util_dataforms_spec.lua Mon Oct 25 21:45:46 2021 +0200 @@ -446,6 +446,20 @@ assert.table(e); assert.string(e.number); end); + + describe("datetime", function () + local f = dataforms.new { { name = "when"; type = "text-single"; datatype = "xs:dateTime" } } -- luacheck: ignore 431 + + it("works", function () + local x = f:form({ when = "2008-08-22T21:09:00Z" }); + assert.equal("2008-08-22T21:09:00Z", x:find("field/value#")) + local d, e = f:data(x); + assert.is_nil(e); + assert.same({ when = 1219439340 }, d); + end); + + end) + end); describe("media element", function () it("produced media element correctly", function ()