aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-08-19 13:20:55 +0100
committerMatthew Wild <mwild1@gmail.com>2018-08-19 13:20:55 +0100
commitef45db165fbbc57f84ed73e0de877ab1b62593f6 (patch)
tree1c56f8d340d6125f35bfd9bd4e694ea7ad49529d /spec
parent25f75ab948bd57a753eeb3c515e4f57694f4ddd2 (diff)
downloadprosody-ef45db165fbbc57f84ed73e0de877ab1b62593f6.tar.gz
prosody-ef45db165fbbc57f84ed73e0de877ab1b62593f6.zip
tests: Add muc/util tests for filtering MUC elements
Diffstat (limited to 'spec')
-rw-r--r--spec/muc_util_spec.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/muc_util_spec.lua b/spec/muc_util_spec.lua
new file mode 100644
index 00000000..cef68e80
--- /dev/null
+++ b/spec/muc_util_spec.lua
@@ -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);