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: Support Jest mocked dates #526

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vbudovski
Copy link
Contributor

Jest provides two different implementations of fake timers - legacy and modern. The legacy implementation works with
RRule, while the modern one does not, as it uses a strict instance check. Compare the toString result of the object if
the value is not a Date instance.


Thanks for contributing to rrule!

To submit a pull request, please verify that you have done the following:

  • Merged in or rebased on the latest master commit
  • Linked to an existing bug or issue describing the bug or feature you're
    addressing
  • Written one or more tests showing that your change works as advertised

@vbudovski vbudovski force-pushed the fix/support-mocked-dates branch 2 times, most recently from 3d3c334 to f09a9f3 Compare June 25, 2022 01:41
Jest provides two different implementations of fake timers - legacy and modern. The legacy implementation works with
RRule, while the modern one does not, as it uses a strict instance check. Compare the toString result of the object if
the value is not a Date instance.
Copy link
Collaborator

@davidgoli davidgoli left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

value instanceof Date ||
(typeof value === 'object' &&
Object.prototype.toString.call(value) === '[object Date]')
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like the lodash isDate implementation - nice

@davidgoli
Copy link
Collaborator

Please resolve the conflicts and I'll merge

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