diff --git a/async/unstable_retry_test.ts b/async/unstable_retry_test.ts index 182a7a70e5a6..083232e687b5 100644 --- a/async/unstable_retry_test.ts +++ b/async/unstable_retry_test.ts @@ -3,6 +3,30 @@ import { assertEquals, assertRejects } from "@std/assert"; import { retry } from "./unstable_retry.ts"; import { RetryError } from "./retry.ts"; +Deno.test("retry() throws if maxTimeout is negative", async () => { + await assertRejects( + async () => await retry(() => {}, { maxTimeout: -1 }), + TypeError, + "Cannot retry as 'maxTimeout' must be positive: current value is -1", + ); +}); + +Deno.test("retry() throws if minTimeout is bigger than maxTimeout", async () => { + await assertRejects( + async () => await retry(() => {}, { maxTimeout: 1, minTimeout: 2 }), + TypeError, + "Cannot retry as 'minTimeout' must be <= 'maxTimeout': current values 'minTimeout=2', 'maxTimeout=1'", + ); +}); + +Deno.test("retry() throws if jitter is bigger than 1", async () => { + await assertRejects( + async () => await retry(() => {}, { jitter: 2 }), + TypeError, + "Cannot retry as 'jitter' must be <= 1: current value is 2", + ); +}); + Deno.test("retry() only retries errors that are retriable with `isRetriable` option", async () => { class HttpError extends Error { status: number;