Mercurial > prosody-hg
comparison spec/util_stanza_spec.lua @ 8597:6e5fbeaca0f4
util.stanza: Fix tests to call error_reply() correctly, and add tests to ensure it vaguely works
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 16 Mar 2018 14:24:53 +0000 |
| parents | 4878e4159e12 |
| children | 282d544d48f4 |
comparison
equal
deleted
inserted
replaced
| 8596:71da54c7f797 | 8597:6e5fbeaca0f4 |
|---|---|
| 132 it("should work for <s>", function() | 132 it("should work for <s>", function() |
| 133 -- Test stanza | 133 -- Test stanza |
| 134 local s = st.stanza("s", { to = "touser", from = "fromuser", id = "123" }) | 134 local s = st.stanza("s", { to = "touser", from = "fromuser", id = "123" }) |
| 135 :tag("child1"); | 135 :tag("child1"); |
| 136 -- Make reply stanza | 136 -- Make reply stanza |
| 137 local r = st.error_reply(s); | 137 local r = st.error_reply(s, "cancel", "service-unavailable"); |
| 138 assert.are.equal(r.name, s.name); | 138 assert.are.equal(r.name, s.name); |
| 139 assert.are.equal(r.id, s.id); | 139 assert.are.equal(r.id, s.id); |
| 140 assert.are.equal(r.attr.to, s.attr.from); | 140 assert.are.equal(r.attr.to, s.attr.from); |
| 141 assert.are.equal(r.attr.from, s.attr.to); | 141 assert.are.equal(r.attr.from, s.attr.to); |
| 142 assert.are.equal(#r.tags, 1); | 142 assert.are.equal(#r.tags, 1); |
| 143 assert.are.equal(r.tags[1].tags[1].name, "service-unavailable"); | |
| 143 end); | 144 end); |
| 144 | 145 |
| 145 it("should work for <iq get>", function() | 146 it("should work for <iq get>", function() |
| 146 -- Test stanza | 147 -- Test stanza |
| 147 local s = st.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "get" }) | 148 local s = st.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "get" }) |
| 148 :tag("child1"); | 149 :tag("child1"); |
| 149 -- Make reply stanza | 150 -- Make reply stanza |
| 150 local r = st.error_reply(s); | 151 local r = st.error_reply(s, "cancel", "service-unavailable"); |
| 151 assert.are.equal(r.name, s.name); | 152 assert.are.equal(r.name, s.name); |
| 152 assert.are.equal(r.id, s.id); | 153 assert.are.equal(r.id, s.id); |
| 153 assert.are.equal(r.attr.to, s.attr.from); | 154 assert.are.equal(r.attr.to, s.attr.from); |
| 154 assert.are.equal(r.attr.from, s.attr.to); | 155 assert.are.equal(r.attr.from, s.attr.to); |
| 155 assert.are.equal(r.attr.type, "error"); | 156 assert.are.equal(r.attr.type, "error"); |
| 156 assert.are.equal(#r.tags, 1); | 157 assert.are.equal(#r.tags, 1); |
| 158 assert.are.equal(r.tags[1].tags[1].name, "service-unavailable"); | |
| 157 end); | 159 end); |
| 158 end); | 160 end); |
| 159 end); | 161 end); |
