aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_jid_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-01-15 16:25:25 +0100
committerKim Alvefur <zash@zash.se>2022-01-15 16:25:25 +0100
commitcced954ac3e55bff2dabb86c555044eb007e44d4 (patch)
tree25ff592845b6021179d182bbbc8db134a08426f6 /spec/util_jid_spec.lua
parent91055b49bba7b0be8f2b25b96b0ae9ce2a4337ff (diff)
downloadprosody-cced954ac3e55bff2dabb86c555044eb007e44d4.tar.gz
prosody-cced954ac3e55bff2dabb86c555044eb007e44d4.zip
util.jid: Explicitly check for nil rather than falsy
A boolean false should blow up.
Diffstat (limited to 'spec/util_jid_spec.lua')
-rw-r--r--spec/util_jid_spec.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/util_jid_spec.lua b/spec/util_jid_spec.lua
index 17cadbee..b92ca06c 100644
--- a/spec/util_jid_spec.lua
+++ b/spec/util_jid_spec.lua
@@ -13,6 +13,11 @@ describe("util.jid", function()
assert.are.equal(jid.join(nil, nil, "c"), nil, "invalid JID is nil");
assert.are.equal(jid.join("a", nil, "c"), nil, "invalid JID is nil");
end);
+ it("should reject invalid arguments", function ()
+ assert.has_error(function () jid.join(false, "bork", nil) end)
+ assert.has_error(function () jid.join(nil, "bork", false) end)
+ assert.has_error(function () jid.join(false, false, false) end)
+ end)
end);
describe("#split()", function()
it("should work", function()
@@ -38,6 +43,9 @@ describe("util.jid", function()
test("@server/resource", nil, nil, nil);
test("@/resource", nil, nil, nil);
end);
+ it("should reject invalid arguments", function ()
+ assert.has_error(function () jid.split(false) end)
+ end)
end);
@@ -59,6 +67,9 @@ describe("util.jid", function()
assert.are.equal(jid.bare("user@@host/resource"), nil, "invalid JID is nil");
assert.are.equal(jid.bare("user@host/"), nil, "invalid JID is nil");
end);
+ it("should reject invalid arguments", function ()
+ assert.has_error(function () jid.bare(false) end)
+ end)
end);
describe("#compare()", function()