Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ritave committed Nov 10, 2022
1 parent 47ac4e7 commit 1c518de
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
8 changes: 4 additions & 4 deletions packages/rpc-methods/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: 0,
functions: 0,
lines: 0,
statements: 0,
branches: 82.85,
functions: 80.85,
lines: 59.77,
statements: 59.77,
},
},
testTimeout: 2500,
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = deepmerge(baseConfig, {
coveragePathIgnorePatterns: ['./src/types'],
coverageThreshold: {
global: {
branches: 98.88,
branches: 98.91,
functions: 98.07,
lines: 99.86,
statements: 99.86,
Expand Down
8 changes: 4 additions & 4 deletions packages/snaps-controllers/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const baseConfig = require('../../jest.config.base');
module.exports = deepmerge(baseConfig, {
coverageThreshold: {
global: {
branches: 0,
functions: 0,
lines: 0,
statements: 0,
branches: 89.03,
functions: 96.44,
lines: 97.06,
statements: 97.06,
},
},
projects: [
Expand Down
2 changes: 2 additions & 0 deletions packages/snaps-controllers/src/snaps/SnapController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
getSnapSourceShasum,
HandlerType,
SnapCaveatType,
SnapManifest,
SnapStatus,
} from '@metamask/snaps-utils';
import {
DEFAULT_SNAP_BUNDLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ describe('BaseSnapExecutor', () => {
jsonrpc: '2.0',
method: 'SnapKeyringEvent',
params: {
args: 'foo',
args: ['foo'],
data: {
chainId: 'eip155:1',
eventName: 'accountsChanged',
Expand Down Expand Up @@ -1578,7 +1578,7 @@ describe('BaseSnapExecutor', () => {
error: {
code: -32603,
data: expect.any(Object),
message: 'JSON-RPC responses must be JSON serializable objects.',
message: 'Received non-JSON-serializable value.',
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,15 @@ export class BaseSnapExecutor {
`No ${handlerName} handler exported for snap "${target}`,
);
// TODO: fix handler args type cast
const result = await this.executeInSnapContext(target, () =>
let result = await this.executeInSnapContext(target, () =>
handler(args as any),
);

// The handler might not return anything, but undefined is not valid JSOn
if (result === undefined) {
result = null;
}

assert(
isValidJson(result),
new TypeError('Received non-JSON-serializable value.'),
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-utils/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = deepmerge(baseConfig, {
],
coverageThreshold: {
global: {
branches: 93.21,
functions: 97.46,
branches: 93.15,
functions: 95.18,
lines: 98.07,
statements: 98.07,
},
Expand Down

0 comments on commit 1c518de

Please sign in to comment.