Software /
code /
prosody
Comparison
spec/muc_util_spec.lua @ 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 |
child | 10715:ad86b93093a3 |
comparison
equal
deleted
inserted
replaced
9212:127af0795e93 | 9213:172f93f752b8 |
---|---|
1 local muc_util; | |
2 | |
3 local st = require "util.stanza"; | |
4 | |
5 do | |
6 local old_pp = package.path; | |
7 package.path = "./?.lib.lua;"..package.path; | |
8 muc_util = require "plugins.muc.util"; | |
9 package.path = old_pp; | |
10 end | |
11 | |
12 describe("muc/util", function () | |
13 describe("filter_muc_x()", function () | |
14 it("correctly filters muc#user", function () | |
15 local stanza = st.message({ to = "to", from = "from", id = "foo" }) | |
16 :tag("x", { xmlns = "http://jabber.org/protocol/muc#user" }) | |
17 :tag("invite", { to = "user@example.com" }); | |
18 | |
19 assert.equal(1, #stanza.tags); | |
20 assert.equal(stanza, muc_util.filter_muc_x(stanza)); | |
21 assert.equal(0, #stanza.tags); | |
22 end); | |
23 | |
24 it("correctly filters muc#user on a cloned stanza", function () | |
25 local stanza = st.message({ to = "to", from = "from", id = "foo" }) | |
26 :tag("x", { xmlns = "http://jabber.org/protocol/muc#user" }) | |
27 :tag("invite", { to = "user@example.com" }); | |
28 | |
29 assert.equal(1, #stanza.tags); | |
30 local filtered = muc_util.filter_muc_x(st.clone(stanza)); | |
31 assert.equal(1, #stanza.tags); | |
32 assert.equal(0, #filtered.tags); | |
33 end); | |
34 end); | |
35 end); |