1- import { describe , expect , it , vi } from "vitest" ;
2- import { createTestClient , http } from "viem" ;
3- import { getWorldAbi } from "./getWorldAbi" ;
1+ import { createTestClient , http , parseAbi } from "viem" ;
42import { foundry } from "viem/chains" ;
3+ import { describe , expect , it , vi } from "vitest" ;
4+ import { mockError , mockMetadata , mockWorldFn } from "./test/mocks" ;
55
6- vi . mock ( "./getFunctions" , ( ) => {
7- const mockGetFunctionsResult = [ { signature : "setNumber(bool)" } , { signature : "batchCall((bytes32,bytes)[])" } ] ;
8- const getFunctions = vi . fn ( ) ;
9- getFunctions . mockResolvedValue ( mockGetFunctionsResult ) ;
6+ vi . doMock ( "../getRecords" , ( ) => ( {
7+ getRecords : vi . fn ( ) . mockResolvedValue ( {
8+ records : mockMetadata ,
9+ } ) ,
10+ } ) ) ;
1011
11- return {
12- getFunctions,
13- } ;
14- } ) ;
12+ const { getWorldAbi } = await import ( "./getWorldAbi" ) ;
1513
1614describe ( "World ABI" , ( ) => {
17- it ( "should concat base and world ABI" , async ( ) => {
15+ it ( "should return the world ABI" , async ( ) => {
1816 const client = createTestClient ( {
1917 chain : foundry ,
2018 mode : "anvil" ,
@@ -28,24 +26,6 @@ describe("World ABI", () => {
2826 toBlock : 0n ,
2927 } ) ;
3028
31- expect ( abi ) . toContainEqual ( {
32- inputs : [
33- {
34- type : "bool" ,
35- } ,
36- ] ,
37- name : "setNumber" ,
38- outputs : [ ] ,
39- stateMutability : "nonpayable" ,
40- type : "function" ,
41- } ) ;
42-
43- expect ( abi ) . not . toContainEqual ( {
44- name : "batchCall" ,
45- type : "function" ,
46- stateMutability : "nonpayable" ,
47- inputs : [ { type : "tuple[]" , components : [ { type : "bytes32" } , { type : "bytes" } ] } ] ,
48- outputs : [ ] ,
49- } ) ;
29+ expect ( abi ) . toEqual ( parseAbi ( [ mockWorldFn , mockError ] ) ) ;
5030 } ) ;
5131} ) ;
0 commit comments