Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Commit

Permalink
fix: better logging on wait test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
baetheus committed Apr 10, 2021
1 parent 36b5248 commit 359c968
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions testing/fns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,23 @@ Deno.test("fns _", () => {
Deno.test("fns wait", async () => {
const within = (high: number, low: number) =>
(value: number): boolean => value >= low && value <= high;
const test = within(110, 90);
const target = 100;
const high = 120;
const low = 80;

const test = within(high, low);
const start = Date.now();
const result = await F.wait(100).then(() => 1);
const result = await F.wait(target).then(() => 1);
const end = Date.now();

const diff = end - start;

assertEquals(result, 1);
assertEquals(test(end - start), true);
assertEquals(
test(diff),
true,
`wait of ${target}ms took ${diff}ms. Acceptable range ${low}-${high}ms`
);
});

Deno.test("fns pipe", () => {
Expand Down

0 comments on commit 359c968

Please sign in to comment.