From 359c9681fdc35f938dc740f3769ca831ae9bdae8 Mon Sep 17 00:00:00 2001 From: Brandon Blaylock Date: Sat, 10 Apr 2021 13:28:38 -0700 Subject: [PATCH] fix: better logging on wait test failure --- testing/fns.test.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/testing/fns.test.ts b/testing/fns.test.ts index 6eee42b..345c5b3 100644 --- a/testing/fns.test.ts +++ b/testing/fns.test.ts @@ -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", () => {