mirror of
https://github.com/littensy/charm.git
synced 2026-10-20 17:51:37 +00:00
fix(charm-sync): run addSignalsToClient outside tracking scope
This commit is contained in:
parent
73fbfb2685
commit
c31e5c5a34
2 changed files with 28 additions and 1 deletions
|
|
@ -405,4 +405,31 @@ test.describe("historical", function()
|
|||
end)
|
||||
end)
|
||||
|
||||
test("addSignalsToClient should ignore tracking context", function()
|
||||
local counter = Charm.atom(0)
|
||||
local payloads: { any }?
|
||||
|
||||
server.connect(function(_client, _payloads)
|
||||
payloads = _payloads
|
||||
end)
|
||||
|
||||
local dispose = Charm.effectScope(function()
|
||||
server.addSignalsToClient("PLAYER_ID", { counter = counter })
|
||||
end)
|
||||
|
||||
server.flush()
|
||||
assert(payloads, "Expected payloads to be sent")
|
||||
assert(payloads[1].type == "init", "Expected first payload to be init")
|
||||
assert(payloads[1].data.counter == 0, "Expected init payload to contain atom 'counter'")
|
||||
|
||||
dispose()
|
||||
|
||||
payloads = nil
|
||||
counter(1)
|
||||
server.flush()
|
||||
assert(payloads, "Expected payloads to be sent")
|
||||
assert(payloads[1].type == "patch", "Expected first payload to be patch")
|
||||
assert(payloads[1].data.counter == 1, "Expected patch payload to contain atom 'counter'")
|
||||
end)
|
||||
|
||||
return {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue