Skip to content

Commit

Permalink
make test cases clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisjiang committed Aug 5, 2024
1 parent 376ebb2 commit ca881a9
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions tests/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ Deno.test('fetch', async (t) => {
}, 500);

const res = await fetchTask.response;
if (res.isErr()) {
assert((res.unwrapErr() as string) === 'cancel');
} else {

res.inspect((x) => {
clearTimeout(timer);
assert(res.isOk());
await res.unwrap().body?.cancel();
}
x.body?.cancel();
}).inspectErr(err => {
assert((err as string) === 'cancel');
});
});

await t.step('Invalid timeout', () => {
Expand All @@ -188,11 +188,8 @@ Deno.test('fetch', async (t) => {
timeout: 1,
});

if (res.isErr()) {
assert((res.unwrapErr() as Error).name === TIMEOUT_ERROR);
} else {
assert(res.isOk());
}
assert(res.isErr());
assert((res.unwrapErr() as Error).name === TIMEOUT_ERROR);
});

await t.step('Fetch not found', async () => {
Expand Down

0 comments on commit ca881a9

Please sign in to comment.