diff options
author | Kim Alvefur <zash@zash.se> | 2021-12-31 14:14:03 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-12-31 14:14:03 +0100 |
commit | 631d7b90030f98f26c23acd6ab14b70d8884500a (patch) | |
tree | b12a367bef26ce8dfb9f2cd6b6c4c22792e8f5db /spec/util_stanza_spec.lua | |
parent | 5ead4102de553047acb50c1201f06b3c84d57e73 (diff) | |
download | prosody-631d7b90030f98f26c23acd6ab14b70d8884500a.tar.gz prosody-631d7b90030f98f26c23acd6ab14b70d8884500a.zip |
util.stanza: Cover :find method in tests
This method is a bit complex so good to have some test coverage
Diffstat (limited to 'spec/util_stanza_spec.lua')
-rw-r--r-- | spec/util_stanza_spec.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/util_stanza_spec.lua b/spec/util_stanza_spec.lua index 3afd67a2..8732a111 100644 --- a/spec/util_stanza_spec.lua +++ b/spec/util_stanza_spec.lua @@ -552,4 +552,16 @@ describe("util.stanza", function() assert.equal("<foo>\n\t\t<bar>\n\t\t\t<baz/>\n\t\t\t<cow>moo</cow>\n\t\t</bar>\n\t</foo>", tostring(s:indent(2, "\t"))); end); + describe("find", function() + it("works", function() + local s = st.stanza("root", { attr = "value" }):tag("child", + { xmlns = "urn:example:not:same"; childattr = "thisvalue" }):text_tag("nested", "text"):reset(); + assert.equal("value", s:find("@attr"), "finds attr") + assert.equal(s:get_child("child", "urn:example:not:same"), s:find("{urn:example:not:same}child"), + "equivalent to get_child") + assert.equal("thisvalue", s:find("{urn:example:not:same}child@childattr"), "finds child attr") + assert.equal("text", s:find("{urn:example:not:same}child/nested#"), "finds nested text") + assert.is_nil(s:find("child"), "respects namespaces") + end); + end); end); |