-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange bug with valid.expirationDate returning incorrect result in 2020 #127
Comments
Hello @jwld, I've looked into this issue a bit and here are my findings. This issue arises with the addition of #99 included in version 8.1.1, where it marks all strings submitted with the year "20" as Explicitly setting the test to verify the date string: '07/2020' works on my machine and should work for you as well. In this configuration the program has the entire year and can confirm its validity. However, with only "20" it will always assume that it's a partial date waiting to be completed by the user. This only occurs for years that are two digit pairs such as I personally don't see a way around this, but one of the contributors would probably know more than me. Let me know if you have any questions. |
I see, thanks for the explanation. Seems like a bug to me, despite being quite a rare edge case. But will just update our tests in this case, so feel free to close! |
Yeah I'm not sure how to classify this either, maybe one of the maintainers would be more qualified to comment. I'll tag @CJGlitter @jplukarski since they are associated with the last commit, maybe they could chime in when time permits. The "problematic" snippet can be found in expiration-year.ts#L62-L64 For now probably best to just update the tests like you said. |
General information
Issue description
Our test suites set the test suite time 2020-01-01 (using mockdate), and we have a test to check that
valid.expirationDate
will returnisValid: true
for "07/20". This works on versions 7 and below, but on version 8 up, it returnsisValid: false
.Changing the tests to any year other than 2020 seems to work fine, but I can't work out why it doesn't work on that particular year.
To replicate it, install jest and mockdate, and then run the following test suite:
On versions 7 and below, this will pass as expected. But on versions 8 and above it fails.
Alternatively you can replicate it by simply setting your own system date to 2020-01-01, and then run
console.log(valid.expirationDate('07/20'))
, which will incorrectly returnisValid: false
on versions 8 and above.The text was updated successfully, but these errors were encountered: