Merge branch 'fix-typo-drive' into 'main'
[ProtonMail-WebClient.git] / packages / hooks / useAsyncError.test.ts
bloba8b543761ee58d5814250124bf449db9702bb06c
1 import { act, renderHook } from '@testing-library/react-hooks';
3 import useAsyncError from './useAsyncError';
5 describe('useAsyncError', () => {
6     it('should return a function', () => {
7         const { result } = renderHook(() => useAsyncError());
8         expect(typeof result.current).toBe('function');
9     });
11     it('should throw an error when called', async () => {
12         const { result, waitForNextUpdate } = renderHook(() => useAsyncError());
13         const throwError = result.current;
15         act(() => {
16             throwError(new Error('Test error'));
17         });
19         await expect(async () => {
20             await waitForNextUpdate();
21         }).rejects.toThrow();
22     });
23 });