1 import { act, renderHook } from '@testing-library/react-hooks';
3 import { useStateRef } from '@proton/hooks';
5 describe('useStateRef', () => {
6 it('should update ref when state is updated', () => {
7 const hook = renderHook(() => useStateRef(0));
10 const [, dispatch] = hook.result.current;
14 const [state, , ref] = hook.result.current;
16 expect(state).toEqual(1);
17 expect(ref.current).toEqual(1);
20 it('should update ref when state is updated with function', () => {
21 const hook = renderHook(() => useStateRef(0));
24 const [, dispatch] = hook.result.current;
25 dispatch((prev) => prev + 1);
28 const [state, , ref] = hook.result.current;
30 expect(state).toEqual(1);
31 expect(ref.current).toEqual(1);