Software /
code /
prosody
Comparison
spec/util_stanza_spec.lua @ 12141:3ac801630b4b
util.stanza: Cover :find method in tests
This method is a bit complex so good to have some test coverage
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 31 Dec 2021 14:14:03 +0100 |
parent | 12139:7d6497294d92 |
child | 12687:5b69ecaf3427 |
comparison
equal
deleted
inserted
replaced
12140:1a4c61253932 | 12141:3ac801630b4b |
---|---|
550 assert.equal("<foo>\n\t<bar>\n\t\t<baz/>\n\t\t<cow>moo</cow>\n\t</bar>\n</foo>", tostring(s:indent())); | 550 assert.equal("<foo>\n\t<bar>\n\t\t<baz/>\n\t\t<cow>moo</cow>\n\t</bar>\n</foo>", tostring(s:indent())); |
551 assert.equal("<foo>\n <bar>\n <baz/>\n <cow>moo</cow>\n </bar>\n</foo>", tostring(s:indent(1, " "))); | 551 assert.equal("<foo>\n <bar>\n <baz/>\n <cow>moo</cow>\n </bar>\n</foo>", tostring(s:indent(1, " "))); |
552 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"))); | 552 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"))); |
553 end); | 553 end); |
554 | 554 |
555 describe("find", function() | |
556 it("works", function() | |
557 local s = st.stanza("root", { attr = "value" }):tag("child", | |
558 { xmlns = "urn:example:not:same"; childattr = "thisvalue" }):text_tag("nested", "text"):reset(); | |
559 assert.equal("value", s:find("@attr"), "finds attr") | |
560 assert.equal(s:get_child("child", "urn:example:not:same"), s:find("{urn:example:not:same}child"), | |
561 "equivalent to get_child") | |
562 assert.equal("thisvalue", s:find("{urn:example:not:same}child@childattr"), "finds child attr") | |
563 assert.equal("text", s:find("{urn:example:not:same}child/nested#"), "finds nested text") | |
564 assert.is_nil(s:find("child"), "respects namespaces") | |
565 end); | |
566 end); | |
555 end); | 567 end); |