@@ -2,8 +2,6 @@ import { NetworkIdByName } from '@synthetixio/contracts-interface';
22import { wei } from '@synthetixio/wei' ;
33import { renderHook } from '@testing-library/react-hooks' ;
44import { BigNumber } from '@ethersproject/bignumber' ;
5- import { JsonRpcProvider } from '@ethersproject/providers' ;
6- import { set } from 'lodash' ;
75import useEthGasPriceQuery , { computeGasFee } from '../src/queries/network/useEthGasPriceQuery' ;
86import { getFakeQueryContext , getWrapper } from '../testUtils' ;
97
@@ -15,9 +13,7 @@ describe('@synthetixio/queries network useEthGasPriceQuery', () => {
1513 // set to 0.015 gwei
1614 const defaultGasPrice = wei ( 0.015 , 9 ) . toBN ( ) ;
1715 //mock provider
18- set ( ctx . provider as JsonRpcProvider , 'getGasPrice' , async ( ) =>
19- Promise . resolve ( defaultGasPrice )
20- ) ;
16+ ctx . provider ! . getGasPrice = jest . fn ( ) . mockResolvedValue ( defaultGasPrice ) ;
2117
2218 const { result, waitFor } = renderHook ( ( ) => useEthGasPriceQuery ( ctx ) , { wrapper } ) ;
2319
@@ -37,9 +33,7 @@ describe('@synthetixio/queries network useEthGasPriceQuery', () => {
3733 // set to 0.015 gwei
3834 const defaultGasPrice = wei ( 0.015 , 9 ) . toBN ( ) ;
3935 //mock provider
40- set ( ctx . provider as JsonRpcProvider , 'getGasPrice' , async ( ) =>
41- Promise . resolve ( defaultGasPrice )
42- ) ;
36+ ctx . provider ! . getGasPrice = jest . fn ( ) . mockResolvedValue ( defaultGasPrice ) ;
4337
4438 const { result, waitFor } = renderHook ( ( ) => useEthGasPriceQuery ( ctx ) , { wrapper } ) ;
4539
@@ -58,10 +52,8 @@ describe('@synthetixio/queries network useEthGasPriceQuery', () => {
5852 // set to 0.015 gwei
5953 const defaultGasPrice = wei ( 0.015 , 9 ) . toBN ( ) ;
6054 //mock provider
61- set ( ctx . provider as ethers . providers . JsonRpcProvider , 'getGasPrice' , async ( ) =>
62- Promise . resolve ( defaultGasPrice )
63- ) ;
6455
56+ ctx . provider ! . getGasPrice = jest . fn ( ) . mockResolvedValue ( defaultGasPrice ) ;
6557 const { result, waitFor } = renderHook ( ( ) => useEthGasPriceQuery ( ctx ) , { wrapper } ) ;
6658
6759 await waitFor ( ( ) => result . current . isSuccess ) ;
@@ -109,9 +101,7 @@ describe('@synthetixio/queries network useEthGasPriceQuery', () => {
109101 // set to 100 gwei
110102 const defaultBaseFeePerGas = wei ( 100 , 9 ) . toBN ( ) ;
111103 //mock provider
112- set ( ctx . provider as JsonRpcProvider , 'getBlock' , async ( ) =>
113- Promise . resolve ( { baseFeePerGas : defaultBaseFeePerGas } )
114- ) ;
104+ ctx . provider ! . getBlock = jest . fn ( ) . mockResolvedValue ( { baseFeePerGas : defaultBaseFeePerGas } ) ;
115105
116106 const { result, waitFor } = renderHook ( ( ) => useEthGasPriceQuery ( ctx ) , { wrapper } ) ;
117107
0 commit comments