1+ import { getLockupContract } from './common'
12import { Options , positionsCreate } from './positionsCreate'
23import { testProviders } from '../common/const'
4+ import { stubTransactionResposeFactory } from '../../common/utils/for-test'
5+
6+ // jest.mock('./common', () => {
7+ // return {
8+ // getLockupContract: jest.fn().mockReturnValue({depositToProperty: (propertyAddress: string, amount: number) => stubTransactionResposeFactory})
9+ // };
10+ // });
11+
12+ jest . mock ( './common' , ( ) => {
13+ return {
14+ getLockupContract : jest . fn ( )
15+ }
16+ } )
317
418describe ( 'positionsCreate.ts' , ( ) => {
519 const propertyAddress = '0x38c4bF6cD20d157EE45553b0fAD13B0c6750b439'
@@ -9,23 +23,26 @@ describe('positionsCreate.ts', () => {
923 fallback : undefined ,
1024 }
1125
12- it ( '' , async ( ) => {
26+ it ( 'success' , async ( ) => {
27+ ( getLockupContract as jest . Mock ) . mockReturnValueOnce ( { depositToProperty : ( propertyAddress : string , amount : number ) => stubTransactionResposeFactory } )
1328 const options : Options = {
1429 provider : testProviders . ropsten ,
1530 propertyAddress,
1631 amount,
1732 overrides,
1833 }
19- const tx = await positionsCreate ( options ) . then ( ( result ) => result )
20- console . log ( tx )
34+ const result = await positionsCreate ( options )
35+ expect ( getLockupContract ) . toHaveBeenCalledTimes ( 1 )
36+ expect ( result ) . toEqual ( stubTransactionResposeFactory )
2137 } )
2238 it ( 'return undefined if network is not valid' , async ( ) => {
39+ ( getLockupContract as jest . Mock ) . mockReturnValueOnce ( undefined )
2340 const options : Options = {
2441 provider : testProviders . polyMumbai ,
2542 propertyAddress,
2643 amount,
2744 overrides,
2845 }
29- const tx = await positionsCreate ( options ) . then ( ( result ) => result )
46+ expect ( await positionsCreate ( options ) ) . toEqual ( undefined )
3047 } )
3148} )
0 commit comments