Comparison

spec/util_dataforms_spec.lua @ 10512:3089086d31fa

util.dataforms: Improve descriptions in tests
author Kim Alvefur <zash@zash.se>
date Mon, 16 Dec 2019 02:02:47 +0100
parent 9243:a4c52e304e6f
child 11026:a086825ed73a
comparison
equal deleted inserted replaced
10511:f89dbf7d03b8 10512:3089086d31fa
108 }, 108 },
109 }); 109 });
110 xform = some_form:form(); 110 xform = some_form:form();
111 end); 111 end);
112 112
113 it("works", function () 113 it("XML serialization looks like it should", function ()
114 assert.truthy(xform); 114 assert.truthy(xform);
115 assert.truthy(st.is_stanza(xform)); 115 assert.truthy(st.is_stanza(xform));
116 assert.equal("x", xform.name); 116 assert.equal("x", xform.name);
117 assert.equal("jabber:x:data", xform.attr.xmlns); 117 assert.equal("jabber:x:data", xform.attr.xmlns);
118 assert.equal("FORM_TYPE", xform:find("field@var")); 118 assert.equal("FORM_TYPE", xform:find("field@var"));
314 assert.equal("xmpp:prosody.im/spec/util.dataforms#1", dataforms.get_type(xform)); 314 assert.equal("xmpp:prosody.im/spec/util.dataforms#1", dataforms.get_type(xform));
315 end); 315 end);
316 end); 316 end);
317 317
318 describe(":data", function () 318 describe(":data", function ()
319 it("works", function () 319 it("returns something", function ()
320 assert.truthy(some_form:data(xform)); 320 assert.truthy(some_form:data(xform));
321 end); 321 end);
322 end); 322 end);
323 323
324 describe("issue1177", function () 324 describe("issue1177", function ()
400 assert.equal("someprefix#the-field", x:find"field@var"); 400 assert.equal("someprefix#the-field", x:find"field@var");
401 assert.equal("hello", x:find"field/value#"); 401 assert.equal("hello", x:find"field/value#");
402 end); 402 end);
403 end); 403 end);
404 404
405 describe("validation", function () 405 describe("datatype validation", function ()
406 local f = dataforms.new { 406 local f = dataforms.new {
407 { 407 {
408 name = "number", 408 name = "number",
409 type = "text-single", 409 type = "text-single",
410 datatype = "xs:integer", 410 datatype = "xs:integer",
411 }, 411 },
412 }; 412 };
413 413
414 it("works", function () 414 it("integer roundtrip works", function ()
415 local d = f:data(f:form({number = 1})); 415 local d = f:data(f:form({number = 1}));
416 assert.equal(1, d.number); 416 assert.equal(1, d.number);
417 end); 417 end);
418 418
419 it("works", function () 419 it("integer error handling works", function ()
420 local d,e = f:data(f:form({number = "nan"})); 420 local d,e = f:data(f:form({number = "nan"}));
421 assert.not_equal(1, d.number); 421 assert.not_equal(1, d.number);
422 assert.table(e); 422 assert.table(e);
423 assert.string(e.number); 423 assert.string(e.number);
424 end); 424 end);