Skip to content

Commit 974ba83

Browse files
committed
lint/tests
1 parent 90b32ff commit 974ba83

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

ui/hooks/useAssetDetails.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState, useEffect } from 'react';
22
import { useSelector, useDispatch } from 'react-redux';
33
import { parseStandardTokenTransactionData } from '../../shared/modules/transaction.utils';
4-
import { getCollectibles, getTokens } from '../ducks/metamask/metamask';
4+
import { getCollectibles } from '../ducks/metamask/metamask';
55
import { ERC1155, ERC721, ERC20 } from '../helpers/constants/common';
66
import {
77
calcTokenAmount,

ui/hooks/useAssetDetails.test.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { Provider } from 'react-redux';
33
import { renderHook } from '@testing-library/react-hooks';
44

55
import configureStore from '../store/store';
6-
import { useAssetDetails } from './useAssetDetails';
76
import * as tokenUtils from '../helpers/utils/token-util';
87
import { 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 = ({
4444
describe('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

Comments
 (0)