@@ -3,9 +3,9 @@ import { Provider } from 'react-redux';
33import { renderHook } from '@testing-library/react-hooks' ;
44
55import configureStore from '../store/store' ;
6- import { useAssetDetails } from './useAssetDetails' ;
76import * as tokenUtils from '../helpers/utils/token-util' ;
87import { ERC20 , ERC721 } from '../helpers/constants/common' ;
8+ import { useAssetDetails } from './useAssetDetails' ;
99
1010// jest.mock('react-redux', () => {
1111// const actual = jest.requireActual('react-redux');
@@ -44,7 +44,6 @@ const renderUseAssetDetails = ({
4444describe ( 'useAssetDetails' , ( ) => {
4545 let getAssetDetailsStub ;
4646 beforeEach ( ( ) => {
47- jest . useFakeTimers ( ) ;
4847 getAssetDetailsStub = jest
4948 . spyOn ( tokenUtils , 'getAssetDetails' )
5049 . mockImplementation ( ( ) => Promise . resolve ( { } ) ) ;
@@ -55,12 +54,14 @@ describe('useAssetDetails', () => {
5554
5655 const transactionData = `0xa9059cbb000000000000000000000000${ toAddress } 000000000000000000000000000000000000000000000000016345785d8a0000` ;
5756
58- const { result } = await renderUseAssetDetails ( {
57+ const { result, waitForNextUpdate } = renderUseAssetDetails ( {
5958 tokenAddress,
6059 userAddress : '0x111' ,
6160 transactionData,
6261 } ) ;
6362
63+ await waitForNextUpdate ;
64+
6465 expect ( result . current ) . toStrictEqual ( {
6566 assetAddress : tokenAddress ,
6667 assetName : undefined ,
@@ -91,12 +92,14 @@ describe('useAssetDetails', () => {
9192 } ) ,
9293 ) ;
9394
94- const { result } = await renderUseAssetDetails ( {
95+ const { result, waitForNextUpdate } = renderUseAssetDetails ( {
9596 tokenAddress,
9697 userAddress,
9798 transactionData,
9899 } ) ;
99100
101+ await waitForNextUpdate ;
102+
100103 expect ( result . current ) . toStrictEqual ( {
101104 assetAddress : tokenAddress ,
102105 assetName : undefined ,
@@ -128,11 +131,13 @@ describe('useAssetDetails', () => {
128131 } ) ,
129132 ) ;
130133
131- const { result } = await renderUseAssetDetails ( {
134+ const { result, waitForNextUpdate } = renderUseAssetDetails ( {
132135 tokenAddress,
133136 transactionData,
134137 } ) ;
135138
139+ await waitForNextUpdate ;
140+
136141 expect ( result . current ) . toStrictEqual ( {
137142 assetAddress : tokenAddress ,
138143 assetName : 'BoredApeYachtClub' ,
0 commit comments