Mercurial > prosody-hg
diff spec/util_stanza_spec.lua @ 12687:5b69ecaf3427
util.stanza: Add add_error() to simplify adding error tags to existing stanzas
Some fiddling is required now in error_reply() to ensure the cursor is in the
same place as before this change (a lot of code apparently uses that feature).
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 29 Aug 2022 14:59:46 +0100 |
| parents | 3ac801630b4b |
| children | 3615590fd9ed |
line wrap: on
line diff
--- a/spec/util_stanza_spec.lua Sun Aug 28 07:51:50 2022 +0100 +++ b/spec/util_stanza_spec.lua Mon Aug 29 14:59:46 2022 +0100 @@ -314,6 +314,20 @@ end) end) + describe("#add_error()", function () + describe("basics", function () + local s = st.stanza("custom", { xmlns = "urn:example:foo" }); + local e = s:add_error("cancel", "not-acceptable", "UNACCEPTABLE!!!! ONE MILLION YEARS DUNGEON!") + :tag("dungeon", { xmlns = "urn:uuid:c9026187-5b05-4e70-b265-c3b6338a7d0f", period="1000000years"}); + assert.equal(s, e); + local typ, cond, text, extra = e:get_error(); + assert.equal("cancel", typ); + assert.equal("not-acceptable", cond); + assert.equal("UNACCEPTABLE!!!! ONE MILLION YEARS DUNGEON!", text); + assert.is_nil(extra); + end) + end) + describe("should reject #invalid", function () local invalid_names = { ["empty string"] = "", ["characters"] = "<>";
