pull/1/head
954270063@qq.com 2020-04-21 19:39:07 +08:00
parent a129cbedc0
commit f8155b795a
1 changed files with 15 additions and 1 deletions

View File

@ -2,7 +2,7 @@
* @Author: early-autumn * @Author: early-autumn
* @Date: 2020-04-20 22:42:46 * @Date: 2020-04-20 22:42:46
* @LastEditors: early-autumn * @LastEditors: early-autumn
* @LastEditTime: 2020-04-21 09:57:39 * @LastEditTime: 2020-04-21 19:38:53
*/ */
import { CancelAction } from '../../src/types'; import { CancelAction } from '../../src/types';
import dispatchRequest from '../../src/core/dispatchRequest'; import dispatchRequest from '../../src/core/dispatchRequest';
@ -29,6 +29,20 @@ describe('测试 src/core/dispatchRequest.ts', () => {
}).then(undefined, (err) => expect(err.response.status).toBe(200)); }).then(undefined, (err) => expect(err.response.status).toBe(200));
}); });
it('自定义错误处理', () => {
dispatchRequest({
adapter({ fail }): any {
fail({});
return 'task';
},
errorHandler(error) {
error.errorHandler = true;
return error;
},
}).then(undefined, (error) => expect(error.errorHandler).toBe(true));
});
it('取消请求', () => { it('取消请求', () => {
let cancel: CancelAction; let cancel: CancelAction;