Mercurial > prosody-hg
comparison spec/util_dataforms_spec.lua @ 9242:68694c1bd960
util.dataforms: Allow field names to be different from the 'var' attribute
This should allow the usage of long prefixes and namespace-like names to
be contained to the XML representation of the form, so that the code can
use more convenient names.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 01 Sep 2018 01:24:46 +0200 |
| parents | e5eb36ee07a2 |
| children | a4c52e304e6f |
comparison
equal
deleted
inserted
replaced
| 9241:2d82a926826f | 9242:68694c1bd960 |
|---|---|
| 384 local data, err = some_form:data(st.stanza("x", {xmlns="jabber:x:data"}), current); | 384 local data, err = some_form:data(st.stanza("x", {xmlns="jabber:x:data"}), current); |
| 385 assert.is.table(data, err); | 385 assert.is.table(data, err); |
| 386 assert.same(expect, data, "got back the same data"); | 386 assert.same(expect, data, "got back the same data"); |
| 387 end); | 387 end); |
| 388 end); | 388 end); |
| 389 | |
| 390 describe("field 'var' property", function () | |
| 391 it("works as expected", function () | |
| 392 local f = dataforms.new { | |
| 393 { | |
| 394 var = "someprefix#the-field", | |
| 395 name = "the_field", | |
| 396 type = "text-single", | |
| 397 } | |
| 398 }; | |
| 399 local x = f:form({the_field = "hello"}); | |
| 400 assert.equal("someprefix#the-field", x:find"field@var"); | |
| 401 assert.equal("hello", x:find"field/value#"); | |
| 402 end); | |
| 403 end); | |
| 389 end); | 404 end); |
| 390 | 405 |
