From c2d50115760df5220a71976610321e5ca69a229a Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 1 Jul 2024 13:12:20 +0100 Subject: [PATCH] Fixing an issue with a JS testcase that depended on dates, when the month changed to July this broke - making the dates fixed to avoid this in future. --- packages/server/src/jsRunner/tests/jsRunner.spec.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/server/src/jsRunner/tests/jsRunner.spec.ts b/packages/server/src/jsRunner/tests/jsRunner.spec.ts index 7448555aac..9d2bd7104d 100644 --- a/packages/server/src/jsRunner/tests/jsRunner.spec.ts +++ b/packages/server/src/jsRunner/tests/jsRunner.spec.ts @@ -91,8 +91,13 @@ describe("jsRunner (using isolated-vm)", () => { }) it("handle test case 2", async () => { + const todayDate = new Date() + // add a year and a month + todayDate.setMonth(new Date().getMonth() + 1) + todayDate.setFullYear(todayDate.getFullYear() + 1) const context = { "Purchase Date": DATE, + today: todayDate.toISOString(), } const result = await processJS( ` @@ -100,7 +105,7 @@ describe("jsRunner (using isolated-vm)", () => { let purchaseyear = purchase.getFullYear(); let purchasemonth = purchase.getMonth(); - var today = new Date (); + var today = new Date($("today")); let todayyear = today.getFullYear(); let todaymonth = today.getMonth(); @@ -113,7 +118,7 @@ describe("jsRunner (using isolated-vm)", () => { context ) expect(result).toBeDefined() - expect(result).toBe(3) + expect(result).toBe(1) }) it("should handle test case 3", async () => {