Skip to content

Commit

Permalink
Used dynamic futer date in testing instead of a static one
Browse files Browse the repository at this point in the history
  • Loading branch information
arpit-chakraborty committed Dec 26, 2024
1 parent 4a8a367 commit a13ae97
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/screens/UserPortal/Settings/Settings.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
Expand Down

0 comments on commit a13ae97

Please sign in to comment.