diff options
author | Kim Alvefur <zash@zash.se> | 2018-03-21 17:03:13 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-03-21 17:03:13 +0100 |
commit | 8e469e0a76088d18886784fba9fc044c692987d4 (patch) | |
tree | 88893d2a3951b82e51a4eaf905f6b77df220eb79 /spec | |
parent | 83f7f40ea2c5109b10c7733ac837fd7a97340c4f (diff) | |
download | prosody-8e469e0a76088d18886784fba9fc044c692987d4.tar.gz prosody-8e469e0a76088d18886784fba9fc044c692987d4.zip |
util.pubsub: Add simple test covering publishing and retrieving an item
Diffstat (limited to 'spec')
-rw-r--r-- | spec/util_pubsub_spec.lua | 24 |
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); |