refactor!: rename derive, map

This commit is contained in:
Richard 2024-05-26 21:31:28 -07:00
parent f2f7a16599
commit b715b81fec
18 changed files with 163 additions and 133 deletions

View file

@ -1,5 +1,6 @@
local atom = require(script.Parent.Parent.Parent.atom)
local sync = require(script.Parent.Parent.Parent.sync)
local patch = require(script.Parent.Parent.Parent.sync.patch)
local types = require(script.Parent.Parent.Parent.types)
return function()
@ -24,7 +25,7 @@ return function()
end)
it("sends state patches", function()
local a = atom({ b = 1, c = 2 })
local a = atom({ b = 1, c = 2 } :: { [string]: number? })
local server = sync.server({ atoms = { a = a }, interval = -1 })
local player: Player, payload: types.SyncPayload
@ -33,13 +34,20 @@ return function()
end)
a({ b = 1, c = 5 })
server:flush(target)
server:_sendPatch(target)
expect(player).to.equal(target)
expect(payload.type).to.equal("patch")
expect(payload.data.a.b).to.never.be.ok()
expect(payload.data.a.c).to.equal(5)
a({ b = 1, d = 1 })
server:_sendPatch(target)
expect(payload.data.a.b).to.never.be.ok()
expect(payload.data.a.c).to.equal(patch.NONE)
expect(payload.data.a.d).to.equal(1)
disconnect()
end)
end