Comparison

spec/util_pubsub_spec.lua @ 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
parent 8564:fd41dc4a78e9
child 8817:9a3066a580ad
comparison
equal deleted inserted replaced
8646:a267dfa9d81d 8647:638ff2ad98e6
26 it("can't delete an already deleted node", function () 26 it("can't delete an already deleted node", function ()
27 assert.falsy(service:delete("princely_musings", true)); 27 assert.falsy(service:delete("princely_musings", true));
28 end); 28 end);
29 end); 29 end);
30 end); 30 end);
31
32 describe("simple publishing", function ()
33 local broadcaster = spy.new(function () end);
34 local service = pubsub.new({ broadcaster = broadcaster; });
35
36 it("creates a node", function ()
37 assert.truthy(service:create("node", true));
38 end);
39
40 it("publishes an item", function ()
41 assert.truthy(service:publish("node", true, "1", "item 1"));
42 end);
43
44 it("called the broadcaster", function ()
45 assert.spy(broadcaster).was_called();
46 end);
47
48 it("should return one item", function ()
49 local ok, ret = service:get_items("node", true);
50 assert.truthy(ok);
51 assert.same({ "1", ["1"] = "item 1" }, ret);
52 end);
53
54 end);
31 end); 55 end);