aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-03-21 17:03:13 +0100
committerKim Alvefur <zash@zash.se>2018-03-21 17:03:13 +0100
commit1292d83c8c7fe30b92702625f61439ce3bcc6b6e (patch)
tree88893d2a3951b82e51a4eaf905f6b77df220eb79 /spec
parent4fa2e21b49959b990089f00d28169aa2a452e275 (diff)
downloadprosody-1292d83c8c7fe30b92702625f61439ce3bcc6b6e.tar.gz
prosody-1292d83c8c7fe30b92702625f61439ce3bcc6b6e.zip
util.pubsub: Add simple test covering publishing and retrieving an item
Diffstat (limited to 'spec')
-rw-r--r--spec/util_pubsub_spec.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/util_pubsub_spec.lua b/spec/util_pubsub_spec.lua
index fac4d675..3221ad6c 100644
--- a/spec/util_pubsub_spec.lua
+++ b/spec/util_pubsub_spec.lua
@@ -28,4 +28,28 @@ describe("util.pubsub", function ()
end);
end);
end);
+
+ describe("simple publishing", function ()
+ local broadcaster = spy.new(function () end);
+ local service = pubsub.new({ broadcaster = broadcaster; });
+
+ it("creates a node", function ()
+ assert.truthy(service:create("node", true));
+ end);
+
+ it("publishes an item", function ()
+ assert.truthy(service:publish("node", true, "1", "item 1"));
+ end);
+
+ it("called the broadcaster", function ()
+ assert.spy(broadcaster).was_called();
+ end);
+
+ it("should return one item", function ()
+ local ok, ret = service:get_items("node", true);
+ assert.truthy(ok);
+ assert.same({ "1", ["1"] = "item 1" }, ret);
+ end);
+
+ end);
end);