Skip to content

Commit

Permalink
test: update useLatest test case (#2586)
Browse files Browse the repository at this point in the history
  • Loading branch information
FEliuyg authored Jul 8, 2024
1 parent 47403c1 commit b2f1218
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/hooks/src/useLatest/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ describe('useLatest', () => {
});

it('useLatest with reference variable should work', async () => {
const { result, rerender } = setUp({});
const val1 = {};
const { result, rerender } = setUp(val1);

expect(result.current.current).toEqual({});
expect(result.current.current).toBe(val1);

rerender([]);
expect(result.current.current).toEqual([]);
const val2 = [];
rerender(val2);
expect(result.current.current).toBe(val2);
});
});

0 comments on commit b2f1218

Please sign in to comment.