Add additional test cases for a leap year
What does this MR do and why?
Adds additional test cases to the nYearsBefore
and nYearsAfter
test suite, testing for the date calculation
when leap day occurs.
Follow up to this discussion: !138003 (comment 1678992713)
Note
When the date in question is Feb 29, the default JS function returns March 01, unfortunately the equivalent calculation in Rails, returns Feb 28. To align the JS date calculation with the rails backend, we manually check for Feb 29 and will return the Feb 28 date for the relevant year, this appears to be the same behaviour in the momentjs and datefns JS libraries.
JS | Rails |
---|---|
Screenshots or screen recordings
No visual changes
How to set up and validate locally
yarn jest spec/frontend/lib/utils/datetime_utility_spec.js
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Ezekiel Kigbo