mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 03:36:11 +00:00
build: install dev deps with wally
This commit is contained in:
parent
0b37f9cd54
commit
7c48bd2fa4
33 changed files with 120 additions and 358 deletions
15
pkgs/vide-charm/tests/spec.luau
Normal file
15
pkgs/vide-charm/tests/spec.luau
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
local ServerScriptService = game:GetService("ServerScriptService")
|
||||
|
||||
local suite = require(ServerScriptService.Tests.suite)
|
||||
|
||||
local describe = suite.describe
|
||||
|
||||
local function spec(name: string)
|
||||
describe(name, function()
|
||||
return require(`./{name}.spec`) :: any
|
||||
end)
|
||||
end
|
||||
|
||||
spec("useAtom")
|
||||
|
||||
return {}
|
||||
40
pkgs/vide-charm/tests/useAtom.spec.luau
Normal file
40
pkgs/vide-charm/tests/useAtom.spec.luau
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local ServerScriptService = game:GetService("ServerScriptService")
|
||||
|
||||
local Charm = require(ReplicatedStorage.Packages.Charm)
|
||||
local Vide = require(ReplicatedStorage.Packages.Vide)
|
||||
local VideCharm = require(ReplicatedStorage.Packages.VideCharm)
|
||||
local suite = require(ServerScriptService.Tests.suite)
|
||||
|
||||
local atom = Charm.atom
|
||||
local root = Vide.root
|
||||
local useAtom = VideCharm.useAtom
|
||||
local test = suite.test
|
||||
|
||||
test("tracks atom state", function()
|
||||
local state = atom(0)
|
||||
local source
|
||||
local cleanup = root(function()
|
||||
source = useAtom(state)
|
||||
end)
|
||||
assert(source() == 0)
|
||||
state(1)
|
||||
assert(source() == 1)
|
||||
cleanup()
|
||||
end)
|
||||
|
||||
test("accepts a selector", function()
|
||||
local state = atom(0)
|
||||
local source
|
||||
local cleanup = root(function()
|
||||
source = useAtom(function()
|
||||
return 2 * state()
|
||||
end)
|
||||
end)
|
||||
assert(source() == 0)
|
||||
state(1)
|
||||
assert(source() == 2)
|
||||
cleanup()
|
||||
end)
|
||||
|
||||
return {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue