Skip to content
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 money routes processSelectedDate #675

Closed
wants to merge 1 commit into from

Conversation

psoleckimoj
Copy link
Contributor

Context

Does this issue have a Jira ticket?

No.

If this is an issue, do we have steps to reproduce?

Intent

What changes are introduced by this PR that correspond to the above ticket?

date function allowed dependency injection so worked for testing, however code that used it did not allow dependency injection.

Would this PR benefit from screenshots?

Considerations

Is there any additional information that would help when reviewing this PR?

Are there any steps required when merging/deploying this PR?

Checklist

  • This PR contains only changes related to the above ticket
  • Tests have been added/updated to cover the change
  • Documentation has been updated where appropriate
  • Tested in Development

@@ -15,14 +21,22 @@ function isValidDateSelection(selectedDate, dateSelection) {
}

function processSelectedDate(selectedDate) {
const dateSelection = getDateSelection(new Date(), parseISO(selectedDate));
const parsedDate = parseISO(selectedDate);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why this suddenly started to fail. The failing tests were calculating incorrect dates due to trying to use today's date with previous years causing a weird set of results. The underlying function getDateSelection is fine and allows for dependency injection but this cannot happen here due to it being a route that's being tested.

I have pulled the current year out of the selectedDate (if parsable) to make new Date() behave as if it's the year from the selectedDate rather than when the tests are run.

Copy link
Contributor

@BarryGeeMOJ BarryGeeMOJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@psoleckimoj psoleckimoj closed this Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants