Skip to content

Commit

Permalink
test(on_leaveplayer): when player leaves unset ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazerbeak12345 committed Nov 30, 2023
1 parent 9481680 commit 3145e42
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions spec/sway_inv_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -645,20 +645,28 @@ describe("Lower-Layer Integration", function ()
assert.True(sway.enabled)
end)
end)
--[[
local onleaveplayer_cb = function (...)
for _, args in ipairs(minetest._register_on_leaveplayer_calls) do
args[1](...)
end
end]]
end
local onjoinplayer_cb = function (...)
for _, args in ipairs(minetest._register_on_joinplayer_calls) do
args[1](...)
end
end
local fakeplayer = {get_player_name=ident"fakeplayer"}
describe("on_leaveplayer", function ()
pending"calls set_context"
it("calls set_context", function ()
local old_sc = sway.set_context
local sc_calls = {}
sway.set_context = function (...)
sc_calls[#sc_calls+1] = {...}
end
onleaveplayer_cb(fakeplayer)
sway.set_context = old_sc
assert.same({{fakeplayer}}, sc_calls)
end)
end)
describe("on_joinplayer", function ()
it("if sway is disabled, the callback does nothing", function ()
Expand Down

0 comments on commit 3145e42

Please sign in to comment.