chore: prepare release, set up workflows

This commit is contained in:
Richard 2024-10-12 17:46:07 -07:00
parent 0416717f6c
commit a5d38b0d6d
58 changed files with 261 additions and 110 deletions

View file

@ -3,14 +3,12 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage")
local store = require(ReplicatedStorage.DevPackages.Charm.store)
return function()
local previous = _G.__DEV__
beforeAll(function()
_G.__DEV__ = true
end)
afterAll(function()
_G.__DEV__ = previous
_G.__DEV__ = nil
end)
afterEach(function()

View file

@ -79,7 +79,7 @@ return function()
local patches = serdes(patch.diff(prevState, nextState))
local applied = patch.apply(prevState, patches)
assert(os.clock() - start < 1e-3, `Performance is not acceptable ({(os.clock() - start) * 1e3}ms)`)
assert(os.clock() - start < 10e-3, `Performance is not acceptable ({(os.clock() - start) * 1e3}ms)`)
for index in next, prevState do
expect(applied[index]).to.equal(nextState[index])

View file

@ -1,17 +1,14 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Charm = require(ReplicatedStorage.DevPackages.Charm)
local store = Charm.store
local store = require(ReplicatedStorage.DevPackages.Charm.store)
return function()
local previous = _G.__DEV__
beforeAll(function()
_G.__DEV__ = true
end)
afterAll(function()
_G.__DEV__ = previous
_G.__DEV__ = nil
end)
afterEach(function()

View file

@ -2,4 +2,4 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TestEZ = require(ReplicatedStorage.DevPackages.TestEZ)
TestEZ.TestBootstrap:run({ script }, TestEZ.Reporters.TextReporter)
TestEZ.TestBootstrap:run({ script.Parent }, TestEZ.Reporters.TextReporter)

View file

@ -8,39 +8,39 @@ local renderHook = require(script.Parent.Parent.utils.renderHook)
return function()
it("tracks atom state", function()
local source = atom(0)
local state = atom(0)
local hook = renderHook(function()
return useAtom(source)
return useAtom(state)
end)
expect(hook.result).to.equal(0)
source(1)
state(1)
expect(hook.result).to.equal(1)
end)
it("accepts a molecule", function()
local source = atom(0)
local state = atom(0)
local hook = renderHook(function()
return useAtom(function()
return 2 * source()
return 2 * state()
end)
end)
expect(hook.result).to.equal(0)
source(1)
state(1)
expect(hook.result).to.equal(2)
end)
it("tracks dependencies", function()
local source = atom(0)
local state = atom(0)
local hook = renderHook(function()
return useAtom(source, { source })
return useAtom(state, { state })
end)
expect(hook.result).to.equal(0)
source(1)
state(1)
expect(hook.result).to.equal(1)
source = atom(0)
state = atom(0)
hook.rerender()
expect(hook.result).to.equal(0)
source(1)
state(1)
expect(hook.result).to.equal(1)
end)
end

View file

@ -0,0 +1,36 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Charm = require(ReplicatedStorage.DevPackages.Charm)
local atom = Charm.atom
local Vide = require(ReplicatedStorage.DevPackages.Vide)
local root = Vide.root
local VideCharm = require(ReplicatedStorage.DevPackages.VideCharm)
local useAtom = VideCharm.useAtom
return function()
it("tracks atom state", function()
local state = atom(0)
local source
local cleanup = root(function()
source = useAtom(state)
end)
expect(source()).to.equal(0)
state(1)
expect(source()).to.equal(1)
cleanup()
end)
it("accepts a molecule", function()
local state = atom(0)
local source
local cleanup = root(function()
source = useAtom(function()
return 2 * state()
end)
end)
expect(source()).to.equal(0)
state(1)
expect(source()).to.equal(2)
cleanup()
end)
end