@@ -3,76 +3,81 @@ import {
33 MOCK_GUILD_MEMBERS_TOTAL ,
44 MOCK_GUILD_ADDRESS ,
55 MOCK_TOKEN ,
6- MOCK_CONTRACT_INTERFACE ,
76} from 'Modules/Guilds/Hooks/fixtures' ;
8- import wagmi , { useContractRead } from 'wagmi' ;
7+ import wagmi , { useContractReads } from 'wagmi' ;
8+ import { ERC20SnapshotRep } from 'contracts/ts-files/ERC20SnapshotRep' ;
9+ import { BaseERC20Guild } from 'contracts/ts-files/BaseERC20Guild' ;
910
1011jest . mock ( 'wagmi' , ( ) => ( {
11- useContractRead : ( ) => ( {
12+ useContractReads : ( ) => ( {
1213 data : MOCK_GUILD_MEMBERS_TOTAL ,
13- isLoading : false ,
14- isError : false ,
1514 } ) ,
15+
16+ useContractEvent : ( ) => jest . fn ( ) ,
1617} ) ) ;
1718
1819describe ( 'useGuildMemberTotal' , ( ) => {
1920 it ( 'should return guild member totals' , ( ) => {
20- const { data, isError, isLoading } = useGuildMemberTotal (
21- MOCK_GUILD_ADDRESS ,
22- MOCK_TOKEN ,
23- false
24- ) ;
21+ const { data } = useGuildMemberTotal ( MOCK_GUILD_ADDRESS , MOCK_TOKEN , false ) ;
2522
2623 expect ( data ) . toMatchInlineSnapshot ( `3` ) ;
27- expect ( isError ) . toBe ( false ) ;
28- expect ( isLoading ) . toBe ( false ) ;
2924 } ) ;
3025
3126 it ( 'should call getTotalHolders when isRepGuild is true' , ( ) => {
3227 const isRepGuild = true ;
33-
3428 const mockUseContractRead = jest
35- . spyOn ( wagmi , 'useContractRead ' )
29+ . spyOn ( wagmi , 'useContractReads ' )
3630 . mockImplementationOnce ( ( ) => ( {
37- ...useContractRead ( {
38- addressOrName : MOCK_GUILD_ADDRESS ,
39- contractInterface : MOCK_CONTRACT_INTERFACE ,
40- functionName : 'getTotalHolders' ,
41- } ) ,
42- isLoading : false ,
43- isError : false ,
31+ ...( useContractReads ( {
32+ contracts : [
33+ {
34+ address : MOCK_TOKEN ,
35+ abi : ERC20SnapshotRep . abi ,
36+ functionName : 'getTotalHolders' ,
37+ } ,
38+ ] ,
39+ } ) as any ) ,
4440 } ) ) ;
4541
4642 useGuildMemberTotal ( MOCK_GUILD_ADDRESS , MOCK_TOKEN , isRepGuild ) ;
4743
48- expect ( mockUseContractRead ) . toBeCalledWith (
49- expect . objectContaining ( {
50- functionName : 'getTotalHolders' ,
51- } )
52- ) ;
44+ expect ( mockUseContractRead ) . toHaveBeenCalledWith ( {
45+ contracts : [
46+ {
47+ address : MOCK_TOKEN ,
48+ abi : ERC20SnapshotRep . abi ,
49+ functionName : 'getTotalHolders' ,
50+ } ,
51+ ] ,
52+ } ) ;
5353 } ) ;
5454
5555 it ( 'should call getTotalMembers when isRepGuild is false' , ( ) => {
5656 const isRepGuild = false ;
57-
5857 const mockUseContractRead = jest
59- . spyOn ( wagmi , 'useContractRead ' )
58+ . spyOn ( wagmi , 'useContractReads ' )
6059 . mockImplementationOnce ( ( ) => ( {
61- ...useContractRead ( {
62- addressOrName : MOCK_GUILD_ADDRESS ,
63- contractInterface : MOCK_CONTRACT_INTERFACE ,
64- functionName : 'getTotalMembers' ,
65- } ) ,
66- isLoading : false ,
67- isError : false ,
60+ ...( useContractReads ( {
61+ contracts : [
62+ {
63+ address : MOCK_GUILD_ADDRESS ,
64+ abi : BaseERC20Guild . abi ,
65+ functionName : 'getTotalMembers' ,
66+ } ,
67+ ] ,
68+ } ) as any ) ,
6869 } ) ) ;
6970
7071 useGuildMemberTotal ( MOCK_GUILD_ADDRESS , MOCK_TOKEN , isRepGuild ) ;
7172
72- expect ( mockUseContractRead ) . toBeCalledWith (
73- expect . objectContaining ( {
74- functionName : 'getTotalMembers' ,
75- } )
76- ) ;
73+ expect ( mockUseContractRead ) . toHaveBeenCalledWith ( {
74+ contracts : [
75+ {
76+ address : MOCK_GUILD_ADDRESS ,
77+ abi : BaseERC20Guild . abi ,
78+ functionName : 'getTotalMembers' ,
79+ } ,
80+ ] ,
81+ } ) ;
7782 } ) ;
7883} ) ;
0 commit comments