aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-08-12 11:34:05 +0100
committerMatthew Wild <mwild1@gmail.com>2018-08-12 11:34:05 +0100
commitd24b7ceb6d771aefc89d827005f5441d3cd2ca6c (patch)
treecd254e11d6448399ebcac80debde1f3023f97a94 /spec
parenta86ca3faa104a5fd4b78e867738f4a7cd1f895fb (diff)
downloadprosody-d24b7ceb6d771aefc89d827005f5441d3cd2ca6c.tar.gz
prosody-d24b7ceb6d771aefc89d827005f5441d3cd2ca6c.zip
util.pubsub tests: Extend publishing tests to check for correct notification behaviour on subscribe/unsubscribe
Diffstat (limited to 'spec')
-rw-r--r--spec/util_pubsub_spec.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/spec/util_pubsub_spec.lua b/spec/util_pubsub_spec.lua
index 0715298c..5ee5a14b 100644
--- a/spec/util_pubsub_spec.lua
+++ b/spec/util_pubsub_spec.lua
@@ -30,7 +30,10 @@ describe("util.pubsub", function ()
end);
describe("simple publishing", function ()
- local broadcaster = spy.new(function () end);
+ local notified;
+ local broadcaster = spy.new(function (notif_type, node_name, subscribers, item)
+ notified = subscribers;
+ end);
local service = pubsub.new({
broadcaster = broadcaster;
});
@@ -45,6 +48,7 @@ describe("util.pubsub", function ()
it("publishes an item", function ()
assert.truthy(service:publish("node", true, "1", "item 1"));
+ assert.truthy(notified["someone"]);
end);
it("called the broadcaster", function ()
@@ -57,6 +61,14 @@ describe("util.pubsub", function ()
assert.same({ "1", ["1"] = "item 1" }, ret);
end);
+ it("lets someone unsubscribe", function ()
+ assert.truthy(service:remove_subscription("node", true, "someone"));
+ end);
+
+ it("does not send notifications after subscription is removed", function ()
+ assert.truthy(service:publish("node", true, "1", "item 1"));
+ assert.is_nil(notified["someone"]);
+ end);
end);
describe("#issue1082", function ()