-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.test.tsx
More file actions
47 lines (42 loc) · 1.47 KB
/
Copy pathindex.test.tsx
File metadata and controls
47 lines (42 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { expect } from '@jest/globals';
import type { RequestOptions, SnapRequest } from '@metamask/snaps-jest';
import { installSnap } from '@metamask/snaps-jest';
describe('Kernel Snap', () => {
let snapRequest: (request: RequestOptions) => SnapRequest;
beforeEach(async () => {
const { request } = await installSnap({
options: {
state: {
activeInterfaceId: '',
},
},
});
snapRequest = request;
});
describe('onRpcRequest', () => {
describe('error', () => {
it('throws an error if the origin of the request is not the kernel snap', async () => {
const response = await snapRequest({
method: 'foo',
origin: 'npm:@metamask/not-kernel',
});
expect(response).toRespondWithError({
code: -32603,
message: `Origin 'npm:@metamask/not-kernel' is not allowed to call 'foo'`,
stack: expect.any(String),
});
});
it('throws an error if the origin is not metamask for getGrantedPermissions', async () => {
const response = await snapRequest({
method: 'permissionsProvider_getGrantedPermissions',
origin: 'npm:@metamask/not-metamask',
});
expect(response).toRespondWithError({
code: -32603,
message: `Origin 'npm:@metamask/not-metamask' is not allowed to call 'permissionsProvider_getGrantedPermissions'`,
stack: expect.any(String),
});
});
});
});
});