From 5a9debb00307f4c903fa29662ed3a6687407ec06 Mon Sep 17 00:00:00 2001 From: "Kossi D. T. Saka" Date: Wed, 27 Mar 2024 12:14:02 +0100 Subject: [PATCH] Extend the test cases to cover the static sleep method --- test/cjs/common.test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/cjs/common.test.js b/test/cjs/common.test.js index 7e02a87..05a82ad 100644 --- a/test/cjs/common.test.js +++ b/test/cjs/common.test.js @@ -59,6 +59,17 @@ describe.each([ expect(result[1]).toBe(expected[1]); expect(elapse).toBeGreaterThanOrEqual(timeout); }); + + it(`Can sleep for ${timeout}ms`, async () => { + let start = process.hrtime.bigint(); + const result = await resolver.sleep(timeout); + let elapse = process.hrtime.bigint() - start; + elapse = Math.ceil(Number(elapse) / 1e6); + + expect(Array.isArray(result)).toBe(true); + expect(result.length).toBe(2); + expect(elapse).toBeGreaterThanOrEqual(timeout); + }); }); /**