spec.stanza spec: Split up util.error related tests
authorKim Alvefur <zash@zash.se>
Sat, 26 Sep 2020 19:00:17 +0200
changeset 11091 cdd4684992f1
parent 11090 2846b6226a8e
child 11092 1f84d0e4d0c4
spec.stanza spec: Split up util.error related tests
spec/util_stanza_spec.lua
--- a/spec/util_stanza_spec.lua	Sat Sep 26 18:09:10 2020 +0200
+++ b/spec/util_stanza_spec.lua	Sat Sep 26 19:00:17 2020 +0200
@@ -232,6 +232,7 @@
 			end, "got stanza of type error");
 		end);
 
+		describe("util.error integration", function ()
 		it("should accept util.error objects", function ()
 			local s = st.message({ to = "touser", from = "fromuser", id = "123", type = "chat" }, "Hello");
 			local e = errors.new({ type = "modify", condition = "not-acceptable", text = "Bork bork bork" }, { by = "this.test" });
@@ -247,12 +248,18 @@
 			assert.are.equal(r.tags[1].tags[1].name, e.condition);
 			assert.are.equal(r.tags[1].tags[2]:get_text(), e.text);
 			assert.are.equal("this.test", r.tags[1].attr.by);
+		end);
 
+		it("should accept util.error objects with an URI", function ()
+			local s = st.message({ to = "touser", from = "fromuser", id = "123", type = "chat" }, "Hello");
 			local gone = errors.new({ condition = "gone", extra = { uri = "file:///dev/null" } })
 			local gonner = st.error_reply(s, gone);
 			assert.are.equal("gone", gonner.tags[1].tags[1].name);
 			assert.are.equal("file:///dev/null", gonner.tags[1].tags[1][1]);
+		end);
 
+		it("should accept util.error objects with application specific error", function ()
+			local s = st.message({ to = "touser", from = "fromuser", id = "123", type = "chat" }, "Hello");
 			local e = errors.new({ condition = "internal-server-error", text = "Namespaced thing happened",
 				extra = {namespace="xmpp:example.test", condition="this-happened"} })
 			local r = st.error_reply(s, e);
@@ -266,6 +273,7 @@
 			assert.are.equal("that-happened", r2.tags[1].tags[3].name);
 			assert.are.equal("here", r2.tags[1].tags[3].attr["another-attribute"]);
 		end);
+		end);
 	end);
 
 	describe("should reject #invalid", function ()