mirror of
https://github.com/littensy/charm.git
synced 2026-10-22 12:41:37 +00:00
refactor: add assertion error messages
This commit is contained in:
parent
bcf02a615f
commit
d56672384a
7 changed files with 74 additions and 80 deletions
|
|
@ -15,9 +15,9 @@ test("tracks atom state", function()
|
|||
local hook = renderHook(function()
|
||||
return useAtom(state)
|
||||
end)
|
||||
assert(hook.result == 0)
|
||||
assert(hook.result == 0, "should return 0")
|
||||
state(1)
|
||||
assert(hook.result == 1)
|
||||
assert(hook.result == 1, "should return 1")
|
||||
end)
|
||||
|
||||
test("accepts a selector", function()
|
||||
|
|
@ -27,9 +27,9 @@ test("accepts a selector", function()
|
|||
return 2 * state()
|
||||
end)
|
||||
end)
|
||||
assert(hook.result == 0)
|
||||
assert(hook.result == 0, "should return 0")
|
||||
state(1)
|
||||
assert(hook.result == 2)
|
||||
assert(hook.result == 2, "should return 2")
|
||||
end)
|
||||
|
||||
test("tracks dependencies", function()
|
||||
|
|
@ -37,14 +37,14 @@ test("tracks dependencies", function()
|
|||
local hook = renderHook(function()
|
||||
return useAtom(state, { state })
|
||||
end)
|
||||
assert(hook.result == 0)
|
||||
assert(hook.result == 0, "should return 0")
|
||||
state(1)
|
||||
assert(hook.result == 1)
|
||||
assert(hook.result == 1, "should return 1")
|
||||
state = atom(0)
|
||||
hook.rerender()
|
||||
assert(hook.result == 0)
|
||||
assert(hook.result == 0, "should return 0")
|
||||
state(1)
|
||||
assert(hook.result == 1)
|
||||
assert(hook.result == 1, "should return 1")
|
||||
end)
|
||||
|
||||
return {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue