test: unit test for async/delay (denoland/deno#7671)

This commit is contained in:
Csaba Okrona 2020-09-25 14:57:31 +02:00 committed by denobot
parent 689f972192
commit 435095d188

14
async/delay_test.ts Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { delay } from "./delay.ts";
import { assert } from "../testing/asserts.ts";
Deno.test("[async] delay", async function (): Promise<void> {
const start = new Date();
const delayedPromise = delay(100);
const result = await delayedPromise;
const diff = new Date().getTime() - start.getTime();
assert(result === undefined);
assert(diff >= 100);
});
export {};