-
Notifications
You must be signed in to change notification settings - Fork 86
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
Fix KDateRange failing tests on prs opened on last day of the month #718
Merged
LianaHarris360
merged 4 commits into
learningequality:develop
from
LianaHarris360:fix-kdaterange-tests
Aug 13, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fec24ae
Update KDateCalendar view to automatically display month of the last …
LianaHarris360 3be1a5f
Update KDATECALENDAR_PROPS within KDateRange test to use set dates
LianaHarris360 13b4365
Update lib/KDateRange/__tests__/KDateRange.spec.js
LianaHarris360 8e78417
Update changelog
LianaHarris360 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious to know why 1 is subtracted from the active month. It means that the activeMonth will always be the month before the lastAllowedDate right? But if we are in January, the previous month would cause the year to also have to be reduced, but I see that activeYearStart is taken only from getFullYear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because of how the Date() constructor in JavaScript sets the months. It uses an integer value to represent the month, beginning with 0 for January to 11 for December.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no, I meant what if the
lastAllowedDate
was for examplenew Date(2024, 0, 1)
, then activeMonth would be 11, but activeYearStart would be 2024, so the active date would be December 2024 instead of December 2023. But I looked at the code and I see that thisactiveYearStart
value is updated in the created hook if this happens, so there is no problem.Anyways I think we could avoid the ternary here, and the check in the created hook if we do something similar to get the previous month:
But it is totally optional, although I think it would clarify the intention that activeMonth and activeYearStart refer to the previous month of the lastAllowedDate.