-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e0536b
commit b7d2fe3
Showing
7 changed files
with
67 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { type TChainId } from '@aelf-web-login/wallet-adapter-base'; | ||
import { getCaContractBase, getIsManagerReadOnly } from '../utils'; | ||
import { getContractBasic } from '@portkey/contracts'; | ||
|
||
afterEach(() => { | ||
jest.unmock('@portkey/contracts'); | ||
}); | ||
jest.mock('@portkey/contracts', () => ({ | ||
getContractBasic: jest.fn(), | ||
})); | ||
|
||
describe('getCaContractBase()', () => { | ||
it('should throw error about chain is not running', async () => { | ||
const chainId = null; | ||
try { | ||
await getCaContractBase(chainId as unknown as TChainId); | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(Error); | ||
expect(error).toHaveProperty('message', `Chain is not running: ${chainId}`); | ||
} | ||
}); | ||
it('should get back contract base', async () => { | ||
const chainId: TChainId = 'tDVW'; | ||
const mockContractBase = { | ||
chainId, | ||
address: '3MLUCydSpntutafc93eEf2L7w7gyoiLT5MaQ1yb5aMrW1vAao', | ||
}; | ||
(getContractBasic as jest.Mock).mockImplementation(() => mockContractBase); | ||
const contractBase = await getCaContractBase(chainId); | ||
expect(contractBase).toMatchObject(mockContractBase); | ||
}); | ||
}); | ||
|
||
describe('getIsManagerReadOnly()', () => { | ||
it('should throw error about chain is not running', async () => { | ||
const chainId = null; | ||
try { | ||
await getIsManagerReadOnly(chainId as unknown as TChainId); | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(Error); | ||
expect(error).toHaveProperty('message', `Chain is not running: ${chainId}`); | ||
} | ||
}); | ||
it('should return false', async () => { | ||
const r = await getIsManagerReadOnly('tDVV'); | ||
expect(r).toBeFalsy(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters