[Unit Test] utils: delay

This commit is contained in:
lts372005
2021-10-30 10:49:49 +07:00
parent 36c92749d7
commit 403f93ec27
3 changed files with 18 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
import "./local/snowflake.ts";
import "./util/validateLength.ts";
import "./util/hasProperty.ts";
import "./util/validate_length.ts";
import "./util/utils.ts";
import "./util/hash.ts";

View File

@@ -1,5 +1,8 @@
import { hasProperty } from "../../src/util/utils.ts";
import { hasProperty, delay } from "../../src/util/utils.ts";
import { assertEquals } from "../deps.ts";
// hasProperty
const obj = { prop: "lts372005" };
Deno.test({
name: "[utils] hasProperty does HAVE property",
@@ -13,3 +16,15 @@ Deno.test({
assertEquals(hasProperty(obj, "lts372005"), false);
},
});
// delay
Deno.test({
name: "[utils] delay 2000 ms",
async fn() {
const before = Date.now();
await delay(2000);
const after = Date.now();
if (after - before < 2000) throw new Error(`delay(2000) delayed ${after - before}ms`);
},
});