Skip to content

Commit

Permalink
fill test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisjiang committed Aug 2, 2024
1 parent 839a0d1 commit 6db6e6b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ Deno.test('fetch', async (t) => {
assert((res.unwrapErr() as Error).message.includes(`Response is invalid json`));
});

await t.step('Ignore timeout when success', async () => {
const res = await fetchT(mockSingle, {
timeout: 10000,
});

assert(res.isOk());
// Leak risk
res.unwrap().body?.cancel();
});

await t.step('Abort fetch by default', async () => {
const fetchTask = fetchT(mockSingle, {
abortable: true,
Expand All @@ -140,7 +150,7 @@ Deno.test('fetch', async (t) => {

setTimeout(() => {
fetchTask.abort();
}, 0);
}, 100);

const res = await fetchTask.response;
assert((res.unwrapErr() as Error).name === ABORT_ERROR);
Expand Down

0 comments on commit 6db6e6b

Please sign in to comment.