From a13ae9755e3073dfc37d1b874d94a0d35d610a24 Mon Sep 17 00:00:00 2001 From: Arpit Chakraborty Date: Thu, 26 Dec 2024 20:14:23 +0530 Subject: [PATCH] Used dynamic futer date in testing instead of a static one --- src/screens/UserPortal/Settings/Settings.spec.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/screens/UserPortal/Settings/Settings.spec.tsx b/src/screens/UserPortal/Settings/Settings.spec.tsx index f04902c5ad..184789ab04 100644 --- a/src/screens/UserPortal/Settings/Settings.spec.tsx +++ b/src/screens/UserPortal/Settings/Settings.spec.tsx @@ -430,12 +430,14 @@ it('prevents selecting future dates for birth date', async () => { 'Birth Date', ) as HTMLInputElement; const today = new Date().toISOString().split('T')[0]; + const futureDate = new Date(); + futureDate.setFullYear(futureDate.getFullYear() + 100); + const futureDateString = futureDate.toISOString().split('T')[0]; // Trying future date - fireEvent.change(birthDateInput, { target: { value: '2100-01-01' } }); - + fireEvent.change(birthDateInput, { target: { value: futureDateString } }); // Checking if value is not updated to future date - expect(birthDateInput.value).not.toBe('2100-01-01'); + expect(birthDateInput.value).not.toBe(futureDateString); // Checking if value set correctly fireEvent.change(birthDateInput, { target: { value: today } });