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');
11 it('should throw an error when called', async () => {
12 const { result, waitForNextUpdate } = renderHook(() => useAsyncError());
13 const throwError = result.current;
16 throwError(new Error('Test error'));
19 await expect(async () => {
20 await waitForNextUpdate();