Skip to main content
Module

x/sleep/test.ts

🦕 module for sleep. You can sleep for a specific amount of time or you can sleep for a random amount of time with this.
Latest
File
// I buy and sell https://FreedomCash.org
import { fail } from "https://deno.land/std@0.210.0/testing/asserts.ts"import { sleep, sleepRandomAmountOfSeconds } from "https://deno.land/x/sleep/mod.ts"

Deno.test("sleep for 2 seconds", async (): Promise<void> => { const sleepStartAt = Date.now() await sleep(2) const sleepEndAt = Date.now() const sleepDuration = sleepEndAt - sleepStartAt if (sleepDuration < 2000 || sleepDuration > 2100) { fail("you should somehow relax") }})
Deno.test("sleep for random amount of seconds between 2 and 4 seconds", async (): Promise< void> => { const sleepStartAt = Date.now() await sleepRandomAmountOfSeconds(2, 4) const sleepEndAt = Date.now() const sleepDuration = sleepEndAt - sleepStartAt if (sleepDuration < 2000 || sleepDuration > 4100) { fail("you should somehow relax") }})