refactor: add assertion error messages

This commit is contained in:
littensy 2025-05-06 11:18:19 -07:00
parent bcf02a615f
commit d56672384a
7 changed files with 74 additions and 80 deletions

View file

@ -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 {}