| 1 | local harness = require "harness"; |
| 2 | local verse = harness.verse; |
| 3 | |
| 4 | return { |
| 5 | { "delivers a chat message between two clients", function (t) |
| 6 | t.client("bob", function (bob) |
| 7 | bob:hook("message", t.cb(function (msg) |
| 8 | assert(msg.attr.from == "alice@"..harness.domain.."/verse-test", "unexpected sender: "..tostring(msg.attr.from)); |
| 9 | assert(msg:get_child_text("body") == "hello bob", "unexpected body"); |
| 10 | t.done(); |
| 11 | end)); |
| 12 | t.client("alice", function (alice) |
| 13 | alice:send(verse.message({ to = bob.jid, type = "chat" }):tag("body"):text("hello bob")); |
| 14 | end); |
| 15 | end); |
| 16 | end }; |
| 17 | |
| 18 | { "receives an error for an unknown IQ", function (t) |
| 19 | t.client("alice", function (c) |
| 20 | t.client("bob", function (bob) |
| 21 | bob:send_iq(verse.iq({ to = c.jid, type = "get" }):tag("query", { xmlns = "urn:example:unknown" }), t.cb(function (reply) |
| 22 | assert(reply.attr.type == "error", "expected an error reply"); |
| 23 | local _, condition = reply:get_error(); |
| 24 | assert(condition == "service-unavailable", "unexpected condition: "..tostring(condition)); |
| 25 | t.done(); |
| 26 | end)); |
| 27 | end); |
| 28 | end); |
| 29 | end }; |
| 30 | }; |