Skip to content

Commit 1a34580

Browse files
committed
test(react/useAtomValue): revert async atom to immediately resolve without 'setTimeout'
1 parent 0261de3 commit 1a34580

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

tests/react/useAtomValue.test.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ it('useAtomValue basic test', async () => {
4040
})
4141

4242
it('useAtomValue with async atom (promise)', async () => {
43-
const asyncAtom = atom(async () => {
44-
await new Promise((resolve) => setTimeout(resolve, 10))
45-
return 42
46-
})
43+
const asyncAtom = atom(() => 42)
4744

4845
const AsyncComponent = () => {
4946
const value = useAtomValue(asyncAtom)
@@ -61,9 +58,7 @@ it('useAtomValue with async atom (promise)', async () => {
6158
),
6259
)
6360

64-
expect(screen.getByText('loading')).toBeInTheDocument()
65-
66-
await act(() => vi.advanceTimersByTimeAsync(10))
61+
await act(() => vi.advanceTimersByTimeAsync(0))
6762
expect(screen.getByText('value: 42')).toBeInTheDocument()
6863
})
6964

0 commit comments

Comments
 (0)