From 68b7e7c082fd0a8404410181db7ec64b92312c49 Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Wed, 31 Dec 2025 15:20:28 +0100 Subject: [PATCH] tests: fix date calculation for previous month in billing limit tests --- apps/api/src/services/__tests__/BillingLimitService.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/api/src/services/__tests__/BillingLimitService.test.ts b/apps/api/src/services/__tests__/BillingLimitService.test.ts index 1d0ff1c..7a7d33d 100644 --- a/apps/api/src/services/__tests__/BillingLimitService.test.ts +++ b/apps/api/src/services/__tests__/BillingLimitService.test.ts @@ -320,7 +320,10 @@ describe('BillingLimitService - Critical Enforcement', () => { data: {billingLimitCampaigns: 10}, }); + // Create a date in the previous month + // Set day to 1 first to avoid month overflow issues (e.g., Jan 31 -> Feb 31 = Mar 3) const lastMonth = new Date(); + lastMonth.setDate(1); lastMonth.setMonth(lastMonth.getMonth() - 1); await prisma.email.create({