-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
25 changed files
with
280 additions
and
119 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
const presets = [ | ||
[ | ||
'@babel/preset-env', | ||
{ targets: { 'node': 'current' } }, | ||
], | ||
] | ||
const plugins = [ | ||
[ | ||
'@babel/plugin-proposal-decorators', | ||
{ legacy: true }, | ||
], | ||
'@babel/plugin-proposal-object-rest-spread', | ||
] | ||
|
||
module.exports = { | ||
env: { | ||
test: { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ targets: { 'node': 'current' } }, | ||
], | ||
], | ||
plugins: [ | ||
[ | ||
'@babel/plugin-proposal-decorators', | ||
{ legacy: true }, | ||
], | ||
], | ||
}, | ||
dev: { presets, plugins }, | ||
test: { presets, plugins }, | ||
production: { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ modules: false }, | ||
], | ||
], | ||
plugins: [ | ||
[ | ||
'@babel/plugin-proposal-decorators', | ||
{ legacy: true }, | ||
], | ||
'@babel/plugin-proposal-object-rest-spread', | ||
], | ||
plugins, | ||
}, | ||
}, | ||
} |
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,42 @@ | ||
// default response result | ||
interface Result { code: number, data: any, msg?: string } | ||
interface ReqFn { | ||
key: string | ||
mock: any | ||
params: object | string[] | ||
} | ||
interface RuntimeOptions { | ||
// for jsonp | ||
callbackName?: string | ||
[key: string]: any | ||
} | ||
interface ReqFnWithAnyParams extends ReqFn { | ||
<T = Result>(params?: any, options?: RuntimeOptions): Promise<T> | ||
} | ||
|
||
export const mockApi: { | ||
'foo': ReqFnWithAnyParams | ||
'bar': ReqFnWithAnyParams | ||
'null': ReqFnWithAnyParams | ||
} | ||
|
||
export const fakeWxApi: { | ||
'fail': ReqFnWithAnyParams | ||
'typeGet': ReqFnWithAnyParams | ||
'noBeforeFn': ReqFnWithAnyParams | ||
'navLoading': ReqFnWithAnyParams | ||
'hideLoading': ReqFnWithAnyParams | ||
'unknownType': ReqFnWithAnyParams | ||
'arrayData': ReqFn & { | ||
<T = Result>( | ||
params: { param1?: any, param2?: any }, | ||
options?: RuntimeOptions | ||
): Promise<T> | ||
} | ||
'objectData': ReqFn & { | ||
<T = Result>( | ||
params: { param1?: any, param2?: any, param3: any }, | ||
options?: RuntimeOptions | ||
): Promise<T> | ||
} | ||
} |
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
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,56 @@ | ||
// default response result | ||
interface Result { code: number, data: any, msg?: string } | ||
interface ReqFn { | ||
key: string | ||
mock: any | ||
params: object | string[] | ||
} | ||
interface RuntimeOptions { | ||
// for jsonp | ||
callbackName?: string | ||
[key: string]: any | ||
} | ||
interface ReqFnWithAnyParams extends ReqFn { | ||
<T = Result>(params?: any, options?: RuntimeOptions): Promise<T> | ||
} | ||
|
||
export const fakeGetApi: { | ||
'acp': ReqFnWithAnyParams | ||
'rta': ReqFnWithAnyParams | ||
'irt': ReqFnWithAnyParams | ||
'afterData': ReqFnWithAnyParams | ||
'mockFnData': ReqFnWithAnyParams | ||
'noAfterData': ReqFnWithAnyParams | ||
'mockObjectData': ReqFnWithAnyParams | ||
'empty-array-params': ReqFnWithAnyParams | ||
'ap': ReqFn & { | ||
<T = Result>( | ||
params: { param1?: any, param2?: any }, | ||
options?: RuntimeOptions | ||
): Promise<T> | ||
} | ||
'op': ReqFn & { | ||
<T = Result>( | ||
params: { param1?: any, param2?: any, param3: any }, | ||
options?: RuntimeOptions | ||
): Promise<T> | ||
} | ||
} | ||
|
||
export const fakePostApi: { | ||
'oh': ReqFnWithAnyParams | ||
'eap': ReqFnWithAnyParams | ||
'hap': ReqFnWithAnyParams | ||
'ap': ReqFn & { | ||
<T = Result>( | ||
params: { param1?: any, param2?: any }, | ||
options?: RuntimeOptions | ||
): Promise<T> | ||
} | ||
'op': ReqFn & { | ||
<T = Result>( | ||
params: { param1?: any, param2?: any, param3: any }, | ||
options?: RuntimeOptions | ||
): Promise<T> | ||
} | ||
} |
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,21 @@ | ||
interface Wx { | ||
request: jest.Mocked<any> | ||
hideLoading: jest.Mocked<any> | ||
showLoading: jest.Mocked<any> | ||
hideNavigationBarLoading: jest.Mocked<any> | ||
showNavigationBarLoading: jest.Mocked<any> | ||
|
||
// just for test | ||
__TEST_DATA__: { | ||
testData?: any | ||
isTestFail?: boolean | ||
} | ||
} | ||
|
||
declare const wx: Wx | ||
|
||
declare namespace NodeJS { | ||
interface Global { | ||
wx: Wx | ||
} | ||
} |
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
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
Oops, something went wrong.