forked from node-modules/mm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
77 lines (62 loc) · 1.78 KB
/
index.d.ts
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
declare function mm(target: any, key: string, prop: any): void;
declare namespace mm {
// export MockMate type for egg-mock;
type MockMate = typeof mm;
type Request = (
url: string | RegExp | { url: string; host: string },
data: any,
headers?: object,
delay?: number
) => MockMate;
type RequestError = (
url: string | RegExp | { url: string; host: string },
reqError: string | Error,
resError: string | Error,
delay?: number
) => MockMate;
/**
* Mock async function error.
*/
function error(mod: any, method: string, error?: string | Error, props?: object, timeout?: number): MockMate;
/**
* Mock async function error once.
*/
function errorOnce(mod: any, method: string, error?: string | Error, props?: object, timeout?: number): MockMate;
/**
* mock return callback(null, data).
*/
function data(mod: any, method: string, data: any, timeout?: number): MockMate;
/**
* mock return callback(null, null).
*/
function empty(mod: any, method: string, timeout?: number): MockMate;
/**
* mock return callback(null, data1, data2).
*/
function datas(mod: any, method: string, datas: any, timeout?: number): MockMate;
/**
* mock function sync throw error
*/
function syncError(mod: any, method: string, error?: string | Error, props?: object): void;
/**
* mock function sync return data
*/
function syncData(mod: any, method: string, data?: any): void;
/**
* mock function sync return nothing
*/
function syncEmpty(mod: any, method: string): void;
/**
* remove all mock effects.
*/
function restore(): MockMate;
const http: {
request: Request;
requestError: RequestError;
};
const https: {
request: Request;
requestError: RequestError;
};
}
export = mm;