Software /
code /
prosody
Comparison
spec/util_stanza_spec.lua @ 11083:4d12a6785531
util.stanza: Support getting 'by' from util.error object
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 26 Sep 2020 17:26:31 +0200 |
parent | 10717:05e4645fc9b3 |
child | 11084:5e09a3389adb |
comparison
equal
deleted
inserted
replaced
11082:c26599a78fae | 11083:4d12a6785531 |
---|---|
232 end, "got stanza of type error"); | 232 end, "got stanza of type error"); |
233 end); | 233 end); |
234 | 234 |
235 it("should accept util.error objects", function () | 235 it("should accept util.error objects", function () |
236 local s = st.message({ to = "touser", from = "fromuser", id = "123", type = "chat" }, "Hello"); | 236 local s = st.message({ to = "touser", from = "fromuser", id = "123", type = "chat" }, "Hello"); |
237 local e = errors.new({ type = "modify", condition = "not-acceptable", text = "Bork bork bork" }); | 237 local e = errors.new({ type = "modify", condition = "not-acceptable", text = "Bork bork bork", extra = { by = "this.test" } }); |
238 local r = st.error_reply(s, e); | 238 local r = st.error_reply(s, e); |
239 | 239 |
240 assert.are.equal(r.name, s.name); | 240 assert.are.equal(r.name, s.name); |
241 assert.are.equal(r.id, s.id); | 241 assert.are.equal(r.id, s.id); |
242 assert.are.equal(r.attr.to, s.attr.from); | 242 assert.are.equal(r.attr.to, s.attr.from); |
244 assert.are.equal(r.attr.type, "error"); | 244 assert.are.equal(r.attr.type, "error"); |
245 assert.are.equal(r.tags[1].name, "error"); | 245 assert.are.equal(r.tags[1].name, "error"); |
246 assert.are.equal(r.tags[1].attr.type, e.type); | 246 assert.are.equal(r.tags[1].attr.type, e.type); |
247 assert.are.equal(r.tags[1].tags[1].name, e.condition); | 247 assert.are.equal(r.tags[1].tags[1].name, e.condition); |
248 assert.are.equal(r.tags[1].tags[2]:get_text(), e.text); | 248 assert.are.equal(r.tags[1].tags[2]:get_text(), e.text); |
249 assert.are.equal("this.test", r.tags[1].attr.by); | |
249 end); | 250 end); |
250 | 251 |
251 end); | 252 end); |
252 | 253 |
253 describe("should reject #invalid", function () | 254 describe("should reject #invalid", function () |