Software /
code /
prosody
Changeset
9213:172f93f752b8
tests: Add muc/util tests for filtering MUC elements
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 19 Aug 2018 13:20:55 +0100 |
parents | 9212:127af0795e93 |
children | 9214:8b2b8f1a911f |
files | spec/muc_util_spec.lua |
diffstat | 1 files changed, 35 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spec/muc_util_spec.lua Sun Aug 19 13:20:55 2018 +0100 @@ -0,0 +1,35 @@ +local muc_util; + +local st = require "util.stanza"; + +do + local old_pp = package.path; + package.path = "./?.lib.lua;"..package.path; + muc_util = require "plugins.muc.util"; + package.path = old_pp; +end + +describe("muc/util", function () + describe("filter_muc_x()", function () + it("correctly filters muc#user", function () + local stanza = st.message({ to = "to", from = "from", id = "foo" }) + :tag("x", { xmlns = "http://jabber.org/protocol/muc#user" }) + :tag("invite", { to = "user@example.com" }); + + assert.equal(1, #stanza.tags); + assert.equal(stanza, muc_util.filter_muc_x(stanza)); + assert.equal(0, #stanza.tags); + end); + + it("correctly filters muc#user on a cloned stanza", function () + local stanza = st.message({ to = "to", from = "from", id = "foo" }) + :tag("x", { xmlns = "http://jabber.org/protocol/muc#user" }) + :tag("invite", { to = "user@example.com" }); + + assert.equal(1, #stanza.tags); + local filtered = muc_util.filter_muc_x(st.clone(stanza)); + assert.equal(1, #stanza.tags); + assert.equal(0, #filtered.tags); + end); + end); +end);