Comparison

spec/util_stanza_spec.lua @ 9732:51583ea2b4fd

util.stanza: Require a type attribute for iq stanzas
author Kim Alvefur <zash@zash.se>
date Fri, 28 Dec 2018 20:49:01 +0100
parent 9673:e7e75b091c96
child 9924:5a2e53bef031
comparison
equal deleted inserted replaced
9731:47121e8dc5b1 9732:51583ea2b4fd
93 end); 93 end);
94 end); 94 end);
95 95
96 describe("#iq()", function() 96 describe("#iq()", function()
97 it("should create an iq stanza", function() 97 it("should create an iq stanza", function()
98 local i = st.iq({ id = "foo" }); 98 local i = st.iq({ type = "get", id = "foo" });
99 assert.are.equal("iq", i.name); 99 assert.are.equal("iq", i.name);
100 assert.are.equal("foo", i.attr.id); 100 assert.are.equal("foo", i.attr.id);
101 end); 101 assert.are.equal("get", i.attr.type);
102 end);
103
104 it("should reject stanzas with no attributes", function ()
105 assert.has.error_match(function ()
106 st.iq();
107 end, "attributes");
108 end);
109
102 110
103 it("should reject stanzas with no id", function () 111 it("should reject stanzas with no id", function ()
104 assert.has.error_match(function () 112 assert.has.error_match(function ()
105 st.iq(); 113 st.iq({ type = "get" });
106 end, "id attribute"); 114 end, "id attribute");
107 115 end);
116
117 it("should reject stanzas with no type", function ()
108 assert.has.error_match(function () 118 assert.has.error_match(function ()
109 st.iq({ foo = "bar" }); 119 st.iq({ id = "foo" });
110 end, "id attribute"); 120 end, "type attribute");
121
111 end); 122 end);
112 end); 123 end);
113 124
114 describe("#presence()", function () 125 describe("#presence()", function ()
115 it("should work", function() 126 it("should work", function()