Skip to content

Commit

Permalink
Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ritave committed Nov 11, 2022
1 parent 368bf75 commit 2627edb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
41 changes: 41 additions & 0 deletions packages/multichain-provider/src/MultiChainProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,47 @@ describe('MultiChainProvider', () => {
expect(result).toBe('foo');
});

it('sends params properly', async () => {
const msg = (params?: any) => ({
method: 'wallet_multiChainRequestHack',
params: {
id: expect.any(String),
jsonrpc: '2.0',
method: 'caip_request',
params: {
chainId: 'eip155:1',
request: {
method: 'asd',
params,
},
},
},
});

const provider = await getProvider();
const request = ethereum.request as jest.MockedFunction<
typeof ethereum.request
>;

request.mockImplementation(async () => 'foo');

await provider.request({
chainId: 'eip155:1',
request: {
method: 'asd',
},
});

await provider.request({
chainId: 'eip155:1',
request: { method: 'asd', params: { prop: 'bar' } },
});

expect(request).toHaveBeenCalledTimes(3);
expect(request).toHaveBeenNthCalledWith(2, msg());
expect(request).toHaveBeenNthCalledWith(3, msg({ prop: 'bar' }));
});

it('generates a random request ID', async () => {
const provider = await getProvider();

Expand Down
6 changes: 3 additions & 3 deletions packages/snaps-execution-environments/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module.exports = deepmerge(baseConfig, {
coveragePathIgnorePatterns: ['./src/index.ts'],
coverageThreshold: {
global: {
branches: 90.11,
branches: 89.47,
functions: 90.26,
lines: 88.14,
statements: 88.14,
lines: 88.19,
statements: 88.19,
},
},
testEnvironment: '<rootDir>/jest.environment.js',
Expand Down

0 comments on commit 2627edb

Please sign in to comment.