-
Notifications
You must be signed in to change notification settings - Fork 645
Expand file tree
/
Copy pathresponse.ts
More file actions
53 lines (51 loc) · 1.23 KB
/
response.ts
File metadata and controls
53 lines (51 loc) · 1.23 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
48
49
50
51
52
53
import type { JSXElement } from '@metamask/snaps-sdk/jsx';
import type {
SnapHandlerInterface,
SnapResponse,
SnapResponseWithInterface,
} from '@metamask/snaps-simulation';
/**
* Get a mock response.
*
* @param options - The options to use.
* @param options.id - The ID to use.
* @param options.response - The response to use.
* @param options.notifications - The notifications to use.
* @param options.getInterface - The `getInterface` function to use.
* @returns The mock response.
*/
export function getMockResponse({
id = 'foo',
response = {
result: 'foo',
},
notifications = [],
getInterface,
}: Partial<SnapResponseWithInterface>): SnapResponse {
return {
id,
response,
notifications,
...(getInterface ? { getInterface } : {}),
};
}
/**
* Get a mock handler interface.
*
* @param content - The content to use.
* @returns The mock handler interface.
*/
export function getMockInterfaceResponse(
content: JSXElement,
): SnapHandlerInterface {
return {
content,
clickElement: jest.fn(),
typeInField: jest.fn(),
selectInDropdown: jest.fn(),
selectFromRadioGroup: jest.fn(),
selectFromSelector: jest.fn(),
uploadFile: jest.fn(),
waitForUpdate: jest.fn(),
};
}