Skip to content

Commit 27a6411

Browse files
committed
test(useRequest): check hasPending status
1 parent 6e60503 commit 27a6411

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/useRequest.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ describe("useRequest", () => {
2121
});
2222

2323
test("check response", async () => {
24-
const [createRequest] = useRequest(getAPIFuncs(true).user.list);
24+
const [createRequest, reqState] = useRequest(getAPIFuncs(true).user.list);
2525

2626
const [data, response] = await createRequest().ready();
2727
expect(data).toStrictEqual(MOCK_DATA_USER_LIST);
2828
expect(response.data).toStrictEqual(MOCK_DATA_USER_LIST);
2929
expect(response.status).toBe(200);
30+
expect(reqState.hasPending.value).toBeFalsy();
3031
});
3132

3233
test("any type (without `request`)", async () => {
@@ -147,10 +148,12 @@ describe("useRequest", () => {
147148
.catch((err) => {
148149
expect(err.isCancel).toBeTruthy();
149150
expect(err.message).toBe("mock_cancel");
151+
expect(hasPending.value).toBeFalsy();
150152
})
151153
.finally(() => {
152154
expect(okFn).toBeCalledTimes(0);
153155
expect(errFn).toBeCalledTimes(1);
156+
expect(hasPending.value).toBeFalsy();
154157
});
155158
cancel("mock_cancel");
156159
expect(okFn).toBeCalledTimes(0);

0 commit comments

Comments
 (0)