Software /
code /
prosody
Changeset
8647:638ff2ad98e6
util.pubsub: Add simple test covering publishing and retrieving an item
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 21 Mar 2018 17:03:13 +0100 |
parents | 8646:a267dfa9d81d |
children | 8648:ca710a71d730 |
files | spec/util_pubsub_spec.lua |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/spec/util_pubsub_spec.lua Wed Mar 21 23:20:59 2018 +0100 +++ b/spec/util_pubsub_spec.lua Wed Mar 21 17:03:13 2018 +0100 @@ -28,4 +28,28 @@ 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);