-
Notifications
You must be signed in to change notification settings - Fork 2
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 5e9212c
Showing
9 changed files
with
78 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{"total": {"lines":{"total":22,"covered":12,"skipped":0,"pct":54.54},"statements":{"total":27,"covered":13,"skipped":0,"pct":48.14},"functions":{"total":2,"covered":1,"skipped":0,"pct":50},"branches":{"total":5,"covered":1,"skipped":0,"pct":20},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}} | ||
,"/Users/aelf/Documents/Projects/aelf/aelf-web-login/packages/bridge/src/utils.ts": {"lines":{"total":22,"covered":12,"skipped":0,"pct":54.54},"functions":{"total":2,"covered":1,"skipped":0,"pct":50},"statements":{"total":27,"covered":13,"skipped":0,"pct":48.14},"branches":{"total":5,"covered":1,"skipped":0,"pct":20}} | ||
{"total": {"lines":{"total":22,"covered":20,"skipped":0,"pct":90.9},"statements":{"total":27,"covered":22,"skipped":0,"pct":81.48},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"branches":{"total":5,"covered":5,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}} | ||
,"/Users/aelf/Documents/Projects/aelf/aelf-web-login/packages/bridge/src/utils.ts": {"lines":{"total":22,"covered":20,"skipped":0,"pct":90.9},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":27,"covered":22,"skipped":0,"pct":81.48},"branches":{"total":5,"covered":5,"skipped":0,"pct":100}} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testsuites name="jest tests" tests="1" failures="0" errors="0" time="0.914"> | ||
<testsuite name="getCaContractBase()" errors="0" failures="0" skipped="0" timestamp="2024-11-22T09:23:05" time="0.605" tests="1"> | ||
<testcase classname="getCaContractBase() should throw error if no chainId" name="getCaContractBase() should throw error if no chainId" time="0.003"> | ||
<testsuites name="jest tests" tests="4" failures="0" errors="0" time="0.919"> | ||
<testsuite name="getCaContractBase()" errors="0" failures="0" skipped="0" timestamp="2024-11-25T04:09:22" time="0.576" tests="4"> | ||
<testcase classname="getCaContractBase() should throw error about chain is not running" name="getCaContractBase() should throw error about chain is not running" time="0.002"> | ||
</testcase> | ||
<testcase classname="getCaContractBase() should get back contract base" name="getCaContractBase() should get back contract base" time="0.001"> | ||
</testcase> | ||
<testcase classname="getIsManagerReadOnly() should throw error about chain is not running" name="getIsManagerReadOnly() should throw error about chain is not running" time="0"> | ||
</testcase> | ||
<testcase classname="getIsManagerReadOnly() should return false" name="getIsManagerReadOnly() should return false" time="0.004"> | ||
</testcase> | ||
</testsuite> | ||
</testsuites> |
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: '', | ||
}; | ||
(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