File tree 3 files changed +22
-12
lines changed
components/Contracts/MyVotingWeight
3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change 1
1
import '@testing-library/jest-dom' ;
2
2
import { render , screen } from '@testing-library/react' ;
3
3
import { Allocation } from 'types' ;
4
- import { useAccount } from 'wagmi' ;
5
-
6
- import { useVotingPower } from 'hooks/index' ;
7
4
8
5
import { MyVotingWeight } from './MyVotingWeight' ;
9
6
10
- jest . mock ( 'wagmi' , ( ) => ( { useAccount : jest . fn ( ) } ) ) ;
11
- jest . mock ( 'hooks/index' , ( ) => ( { useVotingPower : jest . fn ( ) } ) ) ;
7
+ jest . mock ( 'wagmi' , ( ) => ( {
8
+ useAccount : jest . fn ( ) . mockReturnValue ( { address : '0x1234' , isConnected : true } ) ,
9
+ } ) ) ;
10
+ jest . mock ( 'hooks/index' , ( ) => ( { useVotingPower : jest . fn ( ) . mockReturnValue ( { data : '75.05' } ) } ) ) ;
12
11
jest . mock ( 'store/index' , ( ) => ( {
13
12
useAppSelector : jest . fn ( ) . mockReturnValue ( {
14
13
userVotes : { } ,
@@ -33,13 +32,6 @@ const MyVotingWeightExample = () => {
33
32
} ;
34
33
35
34
describe ( '<MyVotingWeight/>' , ( ) => {
36
- beforeEach ( ( ) => {
37
- jest . clearAllMocks ( ) ;
38
-
39
- ( useVotingPower as jest . Mock ) . mockReturnValue ( { data : '75.05' } ) ;
40
- ( useAccount as jest . Mock ) . mockReturnValue ( { address : '0x1234' , isConnected : true } ) ;
41
- } ) ;
42
-
43
35
it ( 'should display title and description' , ( ) => {
44
36
render ( < MyVotingWeightExample /> ) ;
45
37
Original file line number Diff line number Diff line change @@ -4,7 +4,21 @@ import React from 'react';
4
4
5
5
import { Votes } from './Votes' ;
6
6
7
+ jest . mock ( 'wagmi' , ( ) => ( {
8
+ useAccount : jest . fn ( ) . mockReturnValue ( { address : '0x1234' , isConnected : true } ) ,
9
+ } ) ) ;
10
+
11
+ jest . mock ( '@wagmi/core' , ( ) => ( {
12
+ readContract : jest . fn ( ) ,
13
+ readContracts : jest . fn ( ) ,
14
+ } ) ) ;
15
+
16
+ jest . mock ( 'context/Web3ModalProvider' , ( ) => ( {
17
+ queryClient : jest . fn ( ) ,
18
+ } ) ) ;
19
+
7
20
jest . mock ( 'store/index' , ( ) => ( {
21
+ useAppDispatch : jest . fn ( ) ,
8
22
useAppSelector : jest . fn ( ) . mockReturnValue ( {
9
23
lastUserVote : Date . now ( ) ,
10
24
userVotes : {
Original file line number Diff line number Diff line change @@ -33,3 +33,7 @@ jest.mock('wagmi/chains', () => ({
33
33
celo,
34
34
mode,
35
35
} ) ) ;
36
+
37
+ jest . mock ( 'common-util/config/wagmi' , ( ) => ( {
38
+ SUPPORTED_CHAINS : [ { name : 'ethereum' , chainId : 1 } ] ,
39
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments