diff options
Diffstat (limited to 'spec/util_pubsub_spec.lua')
-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); |