From 08c32da0d2c11014178bd59ed144be2a34b992a6 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sat, 1 Feb 2025 15:06:07 +0100 Subject: [PATCH] test(server/utils): fix warnings and explicitly await timeLimit tests --- src/services/utils.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/utils.spec.ts b/src/services/utils.spec.ts index 98cc5bfab..9198ce9c7 100644 --- a/src/services/utils.spec.ts +++ b/src/services/utils.spec.ts @@ -345,7 +345,7 @@ describe("#timeLimit", () => { }, 200); //rej("rejected!"); }); - expect(utils.timeLimit(testPromise, 1_000)).resolves.toBe(resolvedValue); + await expect(utils.timeLimit(testPromise, 1_000)).resolves.toBe(resolvedValue); }); it("when promise execution rejects within timeout, it should return the original promises' rejected value, not the custom set one", async () => { @@ -356,7 +356,7 @@ describe("#timeLimit", () => { rej(rejectedValue); }, 100); }); - expect(utils.timeLimit(testPromise, 200, "Custom Error")).rejects.toThrow(rejectedValue) + await expect(utils.timeLimit(testPromise, 200, "Custom Error")).rejects.toThrow(rejectedValue) }); it("when promise execution exceeds the set timeout, and 'errorMessage' is NOT set, it should reject the promise and display default error message", async () => { @@ -366,7 +366,7 @@ describe("#timeLimit", () => { }, 500); //rej("rejected!"); }); - expect(utils.timeLimit(testPromise, 200)).rejects.toThrow(`Process exceeded time limit 200`) + await expect(utils.timeLimit(testPromise, 200)).rejects.toThrow(`Process exceeded time limit 200`) }); it("when promise execution exceeds the set timeout, and 'errorMessage' is set, it should reject the promise and display set error message", async () => { @@ -377,7 +377,7 @@ describe("#timeLimit", () => { }, 500); //rej("rejected!"); }); - expect(utils.timeLimit(testPromise, 200, customErrorMsg)).rejects.toThrow(customErrorMsg) + await expect(utils.timeLimit(testPromise, 200, customErrorMsg)).rejects.toThrow(customErrorMsg) }); // TriliumNextTODO: since TS avoids this from ever happening – do we need this check?