Skip to content

Commit 726e0cf

Browse files
committed
remove explicit typing and Promis.resolve
1 parent e781885 commit 726e0cf

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

test/useAsync.test.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import { useAsync, UseAsyncReturn } from '../src';
1+
import { useAsync } from '../src';
22
import { renderHook } from '@testing-library/react-hooks';
33

44
interface StarwarsHero {
55
name: string;
66
}
77

8-
type StarwarsHeroArgs = {
9-
asyncFunction: () => Promise<StarwarsHero[]>;
10-
};
11-
128
export const generateMockResponseData = (amount: number = 5): StarwarsHero[] =>
139
[...Array(amount).keys()].map(n => ({
1410
id: n + 1,
@@ -26,11 +22,8 @@ describe('useAync', () => {
2622
const onSuccess = jest.fn();
2723
const onError = jest.fn();
2824

29-
const { result, waitForNextUpdate } = renderHook<
30-
StarwarsHeroArgs,
31-
UseAsyncReturn<StarwarsHero[]>
32-
>(() =>
33-
useAsync<StarwarsHero[], any>(
25+
const { result, waitForNextUpdate } = renderHook(() =>
26+
useAsync(
3427
async () => {
3528
return Promise.resolve(fakeResults);
3629
},
@@ -57,11 +50,8 @@ describe('useAync', () => {
5750
const onSuccess = jest.fn();
5851
const onError = jest.fn();
5952

60-
const { result, waitForNextUpdate } = renderHook<
61-
StarwarsHeroArgs,
62-
UseAsyncReturn<StarwarsHero[]>
63-
>(() =>
64-
useAsync<StarwarsHero[], any>(
53+
const { result, waitForNextUpdate } = renderHook(() =>
54+
useAsync(
6555
async () => {
6656
return Promise.reject(new Error('something went wrong'));
6757
},

0 commit comments

Comments
 (0)