Skip to content

Commit

Permalink
Some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
S-S-X committed Jan 1, 2024
1 parent 09075e1 commit 8c69bdf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/plugin_acl_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("ACL", function()
beerchat.channels["acl-read-role"] = { owner = "SX", color = beerchat.default_channel_color }
beerchat.channels["acl-update-role"] = { owner = "SX", color = beerchat.default_channel_color }
beerchat.channels["acl-delete-role"] = { owner = "SX", color = beerchat.default_channel_color }
beerchat.channels["acl-chat"] = { owner = "SX", color = beerchat.default_channel_color }
end)

before_each(function()
Expand Down Expand Up @@ -112,4 +113,27 @@ describe("ACL", function()
assert.spy(minetest.chat_send_player).called_with("SX", M("emoved.+elete"))
end)

it("read role allows reading messages", function()
beerchat.set_player_channel("SX", "acl-chat")
beerchat.set_player_channel("Sam", "acl-chat")
SX:send_chat_message("/channel_acl #acl-chat Sam read")
spy.on(minetest, "chat_send_player")
SX:send_chat_message("Test message")
-- Channel message allowed and delivered
assert.spy(minetest.chat_send_player).called_with("Sam", M("Test message"))
assert.spy(minetest.chat_send_player).called_with("SX", M("Test message"))
end)

it("read role disallows sending messages", function()
beerchat.set_player_channel("SX", "acl-chat")
beerchat.set_player_channel("Sam", "acl-chat")
SX:send_chat_message("/channel_acl #acl-chat Sam read")
spy.on(minetest, "chat_send_player")
Sam:send_chat_message("Test message")
-- Channel message disallowed and player informed
assert.spy(minetest.chat_send_player).not_called_with("SX", ANY)
assert.spy(minetest.chat_send_player).not_called_with("Sam", M("Test message"))
assert.spy(minetest.chat_send_player).called_with("Sam", ANY)
end)

end)

0 comments on commit 8c69bdf

Please sign in to comment.