Mercurial > prosody-hg
comparison spec/util_dataforms_spec.lua @ 11027:8ed6c5bdbb21
util.dataforms: Add more XEP-0211 media element test coverage
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 16 Aug 2020 20:30:02 +0200 |
| parents | a086825ed73a |
| children | f7f30a3464fe |
comparison
equal
deleted
inserted
replaced
| 11026:a086825ed73a | 11027:8ed6c5bdbb21 |
|---|---|
| 436 assert.not_equal(1, d.number); | 436 assert.not_equal(1, d.number); |
| 437 assert.table(e); | 437 assert.table(e); |
| 438 assert.string(e.number); | 438 assert.string(e.number); |
| 439 end); | 439 end); |
| 440 end); | 440 end); |
| 441 describe("media element", function () | |
| 442 it("produced media element correctly", function () | |
| 443 local f; | |
| 444 for field in xform:childtags("field") do | |
| 445 if field.attr.var == "text-single-with-media-field" then | |
| 446 f = field; | |
| 447 break; | |
| 448 end | |
| 449 end | |
| 450 | |
| 451 assert.truthy(st.is_stanza(f)); | |
| 452 assert.equal("text-single-with-media-field", f.attr.var); | |
| 453 assert.equal("text-single", f.attr.type); | |
| 454 assert.equal("text-single-with-media-label", f.attr.label); | |
| 455 assert.equal(0, iter.count(f:childtags("value"))); | |
| 456 | |
| 457 local m = f:get_child("media", "urn:xmpp:media-element"); | |
| 458 assert.truthy(st.is_stanza(m)); | |
| 459 assert.equal("24", m.attr.height); | |
| 460 assert.equal("32", m.attr.width); | |
| 461 assert.equal(1, iter.count(m:childtags("uri"))); | |
| 462 | |
| 463 local u = m:get_child("uri"); | |
| 464 assert.truthy(st.is_stanza(u)); | |
| 465 assert.equal("image/png", u.attr.type); | |
| 466 assert.equal("data:", u:get_text()); | |
| 467 end); | |
| 468 end); | |
| 441 end); | 469 end); |
| 442 | 470 |
