Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f76280
commit ea75ed5
Showing
4 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
declare function mm(target: any, key: string, prop: any): void; | ||
|
||
declare namespace mm { | ||
/** | ||
* Mock async function error. | ||
*/ | ||
function error(mod: any, method: string, error?: string | Error, props?: object, timeout?: number): typeof mm; | ||
|
||
/** | ||
* mock return callback(null, data). | ||
*/ | ||
function data(mod: any, method: string, data: any, timeout?: number): typeof mm; | ||
|
||
/** | ||
* mock return callback(null, null). | ||
*/ | ||
function empty(mod: any, method: string, timeout?: number): typeof mm; | ||
|
||
/** | ||
* mock return callback(null, data1, data2). | ||
*/ | ||
function datas(mod: any, method: string, datas: any, timeout?: number): typeof mm; | ||
|
||
/** | ||
* 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(): typeof mm; | ||
|
||
const http: { | ||
request: ( | ||
url: string | RegExp | { url: string, host: string}, | ||
data: any, | ||
headers?: object, | ||
delay?: number, | ||
) => typeof mm, | ||
requestError: ( | ||
url: string | RegExp | { url: string, host: string}, | ||
reqError: string | Error, | ||
resError: string | Error, | ||
delay?: number | ||
) => typeof mm, | ||
} | ||
|
||
const https: { | ||
request: ( | ||
url: string | RegExp | { url: string, host: string}, | ||
data: any, | ||
headers?: object, | ||
delay?: number, | ||
) => typeof mm, | ||
requestError: ( | ||
url: string | RegExp | { url: string, host: string}, | ||
reqError: string | Error, | ||
resError: string | Error, | ||
delay?: number | ||
) => typeof mm, | ||
} | ||
|
||
} | ||
|
||
export default mm; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"main": "index.js", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts", | ||
"lib" | ||
], | ||
"scripts": { | ||
|