@lx-frontend/multi-ajax 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/axios.ts +2 -2
- package/coverage/coverage-summary.json +12 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/adapters/index.html +131 -0
- package/coverage/lcov-report/src/adapters/index.ts.html +100 -0
- package/coverage/lcov-report/src/adapters/wx-adapter.ts.html +436 -0
- package/coverage/lcov-report/src/cancelLastSameRequest.ts.html +211 -0
- package/coverage/lcov-report/src/canceller.ts.html +265 -0
- package/coverage/lcov-report/src/compatibleMethods.ts.html +301 -0
- package/coverage/lcov-report/src/duplicateRequestPrevent.ts.html +151 -0
- package/coverage/lcov-report/src/helpers.ts.html +319 -0
- package/coverage/lcov-report/src/index.html +221 -0
- package/coverage/lcov-report/src/index.ts.html +211 -0
- package/coverage/lcov-report/src/methods.ts.html +475 -0
- package/coverage/lcov-report/src/utils.ts.html +334 -0
- package/coverage/lcov.info +610 -0
- package/lib/adapters/wx-adapter.js +10 -9
- package/lib/adapters/wx-adapter.js.map +1 -1
- package/lib/cancelLastSameRequest.d.ts +0 -1
- package/lib/cancelLastSameRequest.js +6 -9
- package/lib/cancelLastSameRequest.js.map +1 -1
- package/lib/canceller.d.ts +11 -2
- package/lib/canceller.js +57 -2
- package/lib/canceller.js.map +1 -1
- package/lib/compatibleMethods.d.ts +3 -3
- package/lib/compatibleMethods.js +1 -1
- package/lib/compatibleMethods.js.map +1 -1
- package/lib/duplicateRequestPrevent.d.ts +1 -1
- package/lib/duplicateRequestPrevent.js +1 -3
- package/lib/duplicateRequestPrevent.js.map +1 -1
- package/lib/helpers.d.ts +3 -2
- package/lib/helpers.js +28 -7
- package/lib/helpers.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +6 -6
- package/lib/index.js.map +1 -1
- package/lib/methods.d.ts +3 -3
- package/lib/methods.js +10 -10
- package/lib/methods.js.map +1 -1
- package/lib/types.d.ts +7 -3
- package/lib/utils.js +0 -1
- package/lib/utils.js.map +1 -1
- package/package.json +10 -10
- package/src/adapters/wx-adapter.ts +19 -13
- package/src/cancelLastSameRequest.ts +5 -5
- package/src/canceller.ts +58 -2
- package/src/compatibleMethods.ts +4 -4
- package/src/duplicateRequestPrevent.ts +3 -4
- package/src/helpers.ts +40 -6
- package/src/index.ts +11 -10
- package/src/methods.ts +26 -19
- package/src/types.ts +8 -4
- package/src/utils.ts +1 -2
- package/tests/duplicateRequestPrevent.test.ts +2 -2
- package/tests/helpers.test.ts +2 -2
- package/tests/index.test.ts +449 -229
- package/tsconfig.json +2 -1
- package/types/global.d.ts +4 -0
package/src/compatibleMethods.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
|
|
10
10
|
export type OldAjaxMethods = 'query' | 'create' | 'deletes' | 'putWay' | 'patchWay'
|
|
11
11
|
|
|
12
|
-
export type CustomAjaxMethods<T extends
|
|
12
|
+
export type CustomAjaxMethods<T extends object, GDataShape extends AnyObj = any> = <DataType = GDataShape>(path: string, config?: Partial<AjaxOption & T>) => (data?: any, expend?: string) => Promise<DataType>
|
|
13
13
|
|
|
14
14
|
type MethodMap = {
|
|
15
15
|
[k in OldAjaxMethods]: AxiosMethods
|
|
@@ -23,7 +23,7 @@ const methodMap: MethodMap = {
|
|
|
23
23
|
patchWay: 'PATCH'
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export const generateCustomMethod = <T extends
|
|
26
|
+
export const generateCustomMethod = <T extends object>(ctx: AjaxInstance<T>, name: OldAjaxMethods): CustomAjaxMethods<T> => <DataType = any>(path: string, config: Partial<AjaxOption | T> = {}) => async (data?: any, expand?: string) => {
|
|
27
27
|
const url = expand ? `${path}/${expand}` : path;
|
|
28
28
|
if (expand) {
|
|
29
29
|
// eslint-disable-next-line no-console
|
|
@@ -51,7 +51,7 @@ export const generateCustomMethod = <T extends Object>(ctx: AjaxInstance<T>, nam
|
|
|
51
51
|
const request = ctx.request<any, DataType>(options);
|
|
52
52
|
|
|
53
53
|
// 缓存请求
|
|
54
|
-
addPendingRequest(hashKey, request)
|
|
54
|
+
addPendingRequest(hashKey, request, options.reUseDuration)
|
|
55
55
|
|
|
56
56
|
const res = await request
|
|
57
57
|
|
|
@@ -61,7 +61,7 @@ export const generateCustomMethod = <T extends Object>(ctx: AjaxInstance<T>, nam
|
|
|
61
61
|
return res
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
function addCompatibleMethods<CusOpts extends
|
|
64
|
+
function addCompatibleMethods<CusOpts extends NonNullable<unknown>>(ctx: AjaxInstance<CusOpts>) {
|
|
65
65
|
ctx.query = generateCustomMethod<CusOpts>(ctx, 'query');
|
|
66
66
|
ctx.create = generateCustomMethod<CusOpts>(ctx, 'create');
|
|
67
67
|
ctx.deletes = generateCustomMethod<CusOpts>(ctx, 'deletes');
|
|
@@ -2,10 +2,9 @@ export { generateRequestHash } from "./utils"
|
|
|
2
2
|
|
|
3
3
|
const pendingRequest: Record<string, any> = {}
|
|
4
4
|
|
|
5
|
-
export function addPendingRequest(hash: string, request: Promise<any>, timeout
|
|
6
|
-
let timer
|
|
5
|
+
export function addPendingRequest(hash: string, request: Promise<any>, timeout: number) {
|
|
7
6
|
pendingRequest[hash] = request
|
|
8
|
-
|
|
7
|
+
setTimeout(() => {
|
|
9
8
|
clearPendingRequest(hash)
|
|
10
9
|
}, timeout)
|
|
11
10
|
}
|
|
@@ -20,4 +19,4 @@ export function checkIfHasPendingRequest(hashKey: string): boolean {
|
|
|
20
19
|
|
|
21
20
|
export function getCachedRequest(hashKey: string) {
|
|
22
21
|
return pendingRequest[hashKey]
|
|
23
|
-
}
|
|
22
|
+
}
|
package/src/helpers.ts
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import qs from 'qs'
|
|
2
2
|
import type { AjaxInstance, AnyObj, ProxyedAttrs } from './types'
|
|
3
|
+
import { callCancellerByCancelKey, hasCancelers } from './canceller'
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 标准化config配置,或根据配置项设置相关的参数
|
|
6
7
|
* 该函数返回的配置对象,应该完全符合axios的配置规范
|
|
7
8
|
* @param {*} config
|
|
8
9
|
*/
|
|
9
|
-
export function normalizeConfig<CusOpt extends
|
|
10
|
+
export function normalizeConfig<CusOpt extends object>(ctx: AjaxInstance<CusOpt>, config: any) {
|
|
10
11
|
const {
|
|
11
|
-
headers = {},
|
|
12
|
+
headers = {},
|
|
13
|
+
sendFormData = false,
|
|
14
|
+
data = undefined,
|
|
15
|
+
params = {},
|
|
16
|
+
baseUrl = '',
|
|
17
|
+
baseURL = '',
|
|
18
|
+
reUseDuration = 300,
|
|
19
|
+
...rest
|
|
12
20
|
} = { ...ctx.$options, ...config };
|
|
13
21
|
// 数据格式为FormData,修改content-type头,以及修改data格式
|
|
14
22
|
const contentType = headers['content-type'] || headers['Content-Type'] || 'application/json';
|
|
@@ -18,8 +26,17 @@ export function normalizeConfig<CusOpt extends Object>(ctx: AjaxInstance<CusOpt>
|
|
|
18
26
|
// baseUrl,支持两种写法,且用户配置的baseUrl优先级最高
|
|
19
27
|
const bUrl = baseUrl || baseURL || ctx.$baseUrl;
|
|
20
28
|
|
|
29
|
+
if (typeof reUseDuration !== 'number' || Number.isNaN(reUseDuration)) {
|
|
30
|
+
throw new Error('ajax配置reUseDuration必须是数字')
|
|
31
|
+
}
|
|
32
|
+
|
|
21
33
|
return {
|
|
22
|
-
headers,
|
|
34
|
+
headers,
|
|
35
|
+
params,
|
|
36
|
+
data: sendData,
|
|
37
|
+
baseURL: bUrl,
|
|
38
|
+
reUseDuration,
|
|
39
|
+
...rest,
|
|
23
40
|
};
|
|
24
41
|
}
|
|
25
42
|
|
|
@@ -32,14 +49,31 @@ export function addInstanceExtendMethod(ctx: any) {
|
|
|
32
49
|
ctx.extend = extend;
|
|
33
50
|
}
|
|
34
51
|
|
|
35
|
-
export function
|
|
36
|
-
const
|
|
52
|
+
export function proxyAxiosInstanceAttrs<S extends {[K in ProxyedAttrs]: any}>(target: AnyObj, source: S): void {
|
|
53
|
+
const attrs: ProxyedAttrs[] = ['request', 'interceptors', 'defaults'];
|
|
37
54
|
// const methods: ProxyedAttrs[] = ['request', 'get', 'post', 'delete', 'head', 'options', 'put', 'patch', 'interceptors'];
|
|
38
55
|
|
|
39
|
-
|
|
56
|
+
attrs.forEach((method) => {
|
|
40
57
|
Object.defineProperty(target, method, {
|
|
41
58
|
value: source[method],
|
|
42
59
|
writable: false,
|
|
43
60
|
});
|
|
44
61
|
});
|
|
45
62
|
}
|
|
63
|
+
|
|
64
|
+
export function proxyAjaxCanceler(ctx: AjaxInstance) {
|
|
65
|
+
ctx.canceller = new Proxy({}, {
|
|
66
|
+
get(target, prop: string) {
|
|
67
|
+
if (!hasCancelers(prop)) {
|
|
68
|
+
return () => {
|
|
69
|
+
const str = `ajax.canceller对象上不存在名为${prop}的函数!`
|
|
70
|
+
console.warn(str)
|
|
71
|
+
return str
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return () => {
|
|
75
|
+
callCancellerByCancelKey(prop)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
2
|
import { wxAdatper } from './adapters/index'
|
|
3
3
|
import addCompatibleMethods from './compatibleMethods'
|
|
4
|
-
import { addInstanceExtendMethod,
|
|
4
|
+
import { addInstanceExtendMethod, proxyAjaxCanceler, proxyAxiosInstanceAttrs } from './helpers'
|
|
5
5
|
import { generateMethod } from './methods'
|
|
6
|
-
import type {
|
|
7
|
-
import { canceller } from './canceller'
|
|
6
|
+
import type {AjaxInstance, AjaxOption, AxiosMethods, RequestMethods} from './types'
|
|
8
7
|
|
|
9
8
|
declare const wx: any;
|
|
10
9
|
|
|
@@ -12,8 +11,8 @@ function isWxapp(): boolean {
|
|
|
12
11
|
return typeof wx !== 'undefined' && typeof wx.request === 'function';
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
export default function initAjax<CusOpts extends
|
|
16
|
-
const ajax = {} as AjaxInstance<CusOpts>;
|
|
14
|
+
export default function initAjax<CusOpts extends object, ResDataShape extends object = any>(options: AjaxOption & CusOpts): AjaxInstance<CusOpts, ResDataShape> {
|
|
15
|
+
const ajax = {} as AjaxInstance<CusOpts, ResDataShape>;
|
|
17
16
|
ajax.$options = options;
|
|
18
17
|
|
|
19
18
|
// 检测wx如果没有自定义的适配器,则使用默认适配器
|
|
@@ -23,13 +22,15 @@ export default function initAjax<CusOpts extends Object, ResDataShape extends Ob
|
|
|
23
22
|
|
|
24
23
|
const requestMethods: AxiosMethods[] = ['POST', 'PUT', 'PATCH', 'DELETE', 'GET', 'HEAD']
|
|
25
24
|
requestMethods.forEach((name: AxiosMethods) => {
|
|
26
|
-
|
|
27
|
-
ajax[
|
|
25
|
+
const queryMethods = name.toLocaleLowerCase() as RequestMethods
|
|
26
|
+
ajax[queryMethods] = generateMethod<CusOpts, ResDataShape>(ajax, name)
|
|
28
27
|
})
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
// 挂载请求的手动取消函数
|
|
30
|
+
proxyAjaxCanceler(ajax)
|
|
31
|
+
|
|
32
|
+
// 把ajax实例上的'request', 'interceptors', defaults属性代理到axios实例上去
|
|
33
|
+
proxyAxiosInstanceAttrs(ajax, ajax.$engine);
|
|
33
34
|
|
|
34
35
|
addCompatibleMethods(ajax)
|
|
35
36
|
|
package/src/methods.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { normalizeConfig } from './helpers'
|
|
2
2
|
import type { AjaxInstance, AjaxOption, AxiosMethods } from './types'
|
|
3
|
-
import {
|
|
3
|
+
import { addCalledCanceller, addCanceller, deleteCancellerByHash } from './canceller'
|
|
4
4
|
import { generateRequestHash } from './utils'
|
|
5
5
|
import { addPendingRequest, checkIfHasPendingRequest, clearPendingRequest, getCachedRequest } from './duplicateRequestPrevent'
|
|
6
6
|
import { addRequestCanceler, clearCancelerByHash, execCanceler } from './cancelLastSameRequest'
|
|
7
7
|
|
|
8
8
|
// GDataShape通过initAjax的第二个泛型参数传入,单独的请求如果不传返回数据的类型,则默认使用GDataShape
|
|
9
9
|
// DataType通过ajax.get, ajax.post等方法的泛型参数传入,如果定义了这个参数,会将GDataShape覆盖
|
|
10
|
-
export interface RequestCreator<COPT extends
|
|
10
|
+
export interface RequestCreator<COPT extends object, GDataShape extends object = any> {
|
|
11
11
|
// request = ajax.get(url, options_1)
|
|
12
12
|
<DataType = GDataShape>(url: string, options?: Partial<AjaxOption & COPT>): {
|
|
13
13
|
// request(params, options_2)
|
|
14
|
-
(params?:
|
|
14
|
+
(params?: object | null, opts?: Partial<AjaxOption & COPT>): Promise<DataType>
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const postLikeMethods = ['PUT', 'POST', 'DELETE' , 'PATCH']
|
|
19
|
-
export const generateMethod = <COPT extends
|
|
19
|
+
export const generateMethod = <COPT extends NonNullable<unknown>, GDataShape extends object = any>(ajax: AjaxInstance<COPT>, method: AxiosMethods): RequestCreator<COPT, GDataShape> =>
|
|
20
20
|
/**
|
|
21
21
|
*
|
|
22
22
|
* @param url 完整的请求url链接
|
|
@@ -30,7 +30,7 @@ export const generateMethod = <COPT extends Object = {}, GDataShape extends Obje
|
|
|
30
30
|
* @param opts ajax参数,拥有最高优先级
|
|
31
31
|
* @returns 请求数据
|
|
32
32
|
*/
|
|
33
|
-
async (params?:
|
|
33
|
+
async (params?: object | null, opts?: Partial<AjaxOption & COPT>) => {
|
|
34
34
|
const mergedOptions = { ...options, ...opts }
|
|
35
35
|
const isPostLikeMethod = postLikeMethods.includes(method)
|
|
36
36
|
|
|
@@ -72,11 +72,15 @@ export const generateMethod = <COPT extends Object = {}, GDataShape extends Obje
|
|
|
72
72
|
finalOpts.signal = controller.signal
|
|
73
73
|
|
|
74
74
|
if (typeof mergedOptions.cancelKey !== 'undefined') {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
addCanceller(
|
|
76
|
+
mergedOptions.cancelKey,
|
|
77
|
+
hashKey,
|
|
78
|
+
() => {
|
|
79
|
+
controller.abort.call(controller)
|
|
80
|
+
// 删除挂载在ajax上的请求中断函数
|
|
81
|
+
deleteCancellerByHash(mergedOptions.cancelKey as string, hashKey)
|
|
82
|
+
}
|
|
83
|
+
)
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
// 缓存当前请求的取消函数,假如后续有相同的url请求需要取消该请求,可以通过这里缓存的函数实现(只针对get请求)
|
|
@@ -97,27 +101,30 @@ export const generateMethod = <COPT extends Object = {}, GDataShape extends Obje
|
|
|
97
101
|
// 此时取消函数还是undefined,所以这里提供默认取消函数
|
|
98
102
|
|
|
99
103
|
if (typeof mergedOptions.cancelKey !== 'undefined') {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
addCanceller(
|
|
105
|
+
mergedOptions.cancelKey,
|
|
106
|
+
hashKey,
|
|
107
|
+
() => {
|
|
108
|
+
// 默认函数将已经调用的取消函数名称记录下来,在adapter中走到发送请求的逻辑时,直接中断即可
|
|
109
|
+
addCalledCanceller(mergedOptions.cancelKey as string, hashKey, true)
|
|
110
|
+
deleteCancellerByHash(mergedOptions.cancelKey as string, hashKey)
|
|
111
|
+
}
|
|
112
|
+
)
|
|
105
113
|
}
|
|
106
|
-
|
|
107
114
|
}
|
|
108
115
|
|
|
109
116
|
try {
|
|
110
117
|
const request = ajax.request<any, DataType>(finalOpts)
|
|
111
|
-
addPendingRequest(hashKey, request)
|
|
118
|
+
addPendingRequest(hashKey, request, finalOpts.reUseDuration)
|
|
112
119
|
return await request
|
|
113
120
|
} catch (e) {
|
|
114
121
|
return Promise.reject(e)
|
|
115
122
|
} finally {
|
|
116
123
|
// 请求成功,删除ajax.canceller上对应的取消函数
|
|
117
|
-
|
|
124
|
+
deleteCancellerByHash(finalOpts.cancelKey, hashKey)
|
|
118
125
|
// 删除用于取消相同URL请求功能而缓存的取消函数
|
|
119
126
|
clearCancelerByHash(finalOpts.url, hashKey)
|
|
120
|
-
// 删除缓存的请求(用于复用
|
|
127
|
+
// 删除缓存的请求(用于复用finalOpts.reUseDuration内完全相同的多个请求)
|
|
121
128
|
clearPendingRequest(hashKey)
|
|
122
129
|
}
|
|
123
130
|
}
|
package/src/types.ts
CHANGED
|
@@ -11,18 +11,21 @@ export interface AjaxOption extends AxiosRequestConfig {
|
|
|
11
11
|
cancelKey?: string
|
|
12
12
|
/** 如果有值,则请求直接resolve这个值,阻断请求发送。用于开发mock数据 */
|
|
13
13
|
mock?: any
|
|
14
|
-
|
|
14
|
+
/** 如果请求的URL和method与一个pending状态的请求相同,是否要终止前面的请求 */
|
|
15
15
|
cancelLastSameUrl?: boolean
|
|
16
|
+
/** 防重设置,在此时间内触发的相同请求会复用上一个处于pending状态的请求,单位为ms。请求返回后,该参数自动失效。 */
|
|
17
|
+
reUseDuration?: number
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export type RequestMethods = 'get' | 'post' | 'patch' | 'put' | 'delete' | 'head'
|
|
19
21
|
|
|
20
|
-
export type ProxyedAttrs = 'request' | 'interceptors'
|
|
22
|
+
// export type ProxyedAttrs = 'request' | 'interceptors'
|
|
23
|
+
export type ProxyedAttrs = keyof Omit<AxiosInstance, RequestMethods>
|
|
21
24
|
|
|
22
25
|
export type CancellerType = {
|
|
23
|
-
[K: string]: () => void
|
|
26
|
+
[K: string]: () => void | undefined
|
|
24
27
|
}
|
|
25
|
-
export interface AjaxInstance<CusOpt extends
|
|
28
|
+
export interface AjaxInstance<CusOpt extends NonNullable<unknown> = any, DataShape extends object = any> extends Pick<AxiosInstance, ProxyedAttrs> {
|
|
26
29
|
/** @deprecated 即将废弃,请使用ajax.get方法替换 */
|
|
27
30
|
query: CustomAjaxMethods<CusOpt, DataShape>
|
|
28
31
|
/** @deprecated 即将废弃,请使用ajax.post方法替换 */
|
|
@@ -39,6 +42,7 @@ export interface AjaxInstance<CusOpt extends Object = {}, DataShape extends Obje
|
|
|
39
42
|
put: RequestCreator<CusOpt, DataShape>
|
|
40
43
|
delete: RequestCreator<CusOpt, DataShape>
|
|
41
44
|
patch: RequestCreator<CusOpt, DataShape>
|
|
45
|
+
extend: (obj: object) => void
|
|
42
46
|
canceller: CancellerType
|
|
43
47
|
$baseUrl: string
|
|
44
48
|
$options: AjaxOption
|
package/src/utils.ts
CHANGED
|
@@ -21,7 +21,7 @@ describe('generateRequestHash测试', () => {
|
|
|
21
21
|
|
|
22
22
|
describe('addPendingRequest测试', () => {
|
|
23
23
|
test('添加删除测试', () => {
|
|
24
|
-
addPendingRequest('123', Promise.resolve({a: 1}))
|
|
24
|
+
addPendingRequest('123', Promise.resolve({a: 1}), 300)
|
|
25
25
|
expect(getCachedRequest('123')).toEqual(Promise.resolve({a: 1}))
|
|
26
26
|
expect(checkIfHasPendingRequest('123')).toBe(true)
|
|
27
27
|
clearPendingRequest('123')
|
|
@@ -29,7 +29,7 @@ describe('addPendingRequest测试', () => {
|
|
|
29
29
|
expect(checkIfHasPendingRequest('123')).toBe(false)
|
|
30
30
|
})
|
|
31
31
|
test('超时删除测试', (done) => {
|
|
32
|
-
addPendingRequest('123', Promise.resolve({a: 1}))
|
|
32
|
+
addPendingRequest('123', Promise.resolve({a: 1}), 500)
|
|
33
33
|
expect(getCachedRequest('123')).toEqual(Promise.resolve({a: 1}))
|
|
34
34
|
setTimeout(() => {
|
|
35
35
|
expect(getCachedRequest('123')).toBeUndefined()
|
package/tests/helpers.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { addInstanceExtendMethod, normalizeConfig, proxyAxiosMethods } from '../lib/helpers'
|
|
2
|
-
import qs
|
|
2
|
+
import qs = require('qs')
|
|
3
3
|
import type { AjaxInstance } from '../lib/types.d'
|
|
4
4
|
|
|
5
5
|
describe('标准化Ajax配置函数normalizeConfig测试', () => {
|
|
@@ -70,4 +70,4 @@ describe('addInstanceExtendMethod测试', () => {
|
|
|
70
70
|
expect(source.testFn).toHaveBeenCalled()
|
|
71
71
|
expect(ctx.testAttr).toBe('tst')
|
|
72
72
|
})
|
|
73
|
-
})
|
|
73
|
+
})
|