-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
Add toBeValidDate matcher #133
Add toBeValidDate matcher #133
Conversation
24e9099
to
374d019
Compare
Codecov Report
@@ Coverage Diff @@
## master #133 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 90 92 +2
Lines 425 434 +9
Branches 70 72 +2
=====================================
+ Hits 425 434 +9
Continue to review full report at Codecov.
|
@@ -0,0 +1,7 @@ | |||
let is = type => value => Object.prototype.toString.call(value) === `[object ${type}]`; |
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 might be a useful function to pull out into utils
and then import here
|
||
let isValidDate = value => hasDateType(value) && !isNaN(value) && !isNaN(value.getTime()); | ||
|
||
export default expected => isValidDate(expected); |
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 can just be:
export default isValidDate;
We don't need both the left and right hand sides of the invocation :)
@@ -0,0 +1,7 @@ | |||
let is = type => value => Object.prototype.toString.call(value) === `[object ${type}]`; | |||
|
|||
let hasDateType = is('Date'); |
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.
Would it be possible to use const
for consistency with other matchers?
Love this @tejasbubane I've added a couple of minor nitpicks but looks awesome! Would you be able to merge master in too to fix the conflicts? |
374d019
to
01a6dca
Compare
@mattphillips I have updated both |
Thanks @tejasbubane |
Issue: #117
What
Add new matcher
toBeValidDate
.Why
As suggested in the issue.
Notes
Housekeeping
yarn contributor
)