-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
normalize getters and setters (fixes #3058) #3064
Conversation
@makepanic thanks |
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.
👍 just a couple tweaks and we can merge.
* | ||
* @api private | ||
* @param {number|string} ms | ||
* @return {Runnable|number} ms or Runnable instance. | ||
*/ | ||
Runnable.prototype.slow = function (ms) { | ||
if (typeof ms === 'undefined') { | ||
if (!arguments.length || typeof ms === 'undefined') { |
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 think we can drop the ms
check
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've initially removed the ms
check but tests were failing here.
I'm unsure if removing the ms check will introduce a breaking change.
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.
ugh, hum, let me think about this.
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.
that test is invalid and should be removed, but it's also a breaking change, so let's leave it for now.
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.
The reason why you test fails, is because when you invoke run.slow(undefined);
argument.length
is equal to 1. Instead of checking the number of arguments passed, you should just check if ms
is undefined. You can do something like this:
if(!ms) {
....
}
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.
@fesebuv that's correct. but we just want to leave as-is for now. there's no change necessary here, since it'll be breaking.
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.
gotcha!
lib/suite.js
Outdated
@@ -165,7 +165,7 @@ Suite.prototype.slow = function (ms) { | |||
}; | |||
|
|||
/** | |||
* Sets whether to bail after first error. | |||
* Sets or gets whether to bail after first error. |
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.
maybe just Set or get
like the others?
lib/context.js
Outdated
* | ||
* @api private | ||
* @param {boolean} enabled | ||
* @return {Context} self | ||
*/ | ||
Context.prototype.enableTimeouts = function (enabled) { | ||
if (!arguments.length) { |
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.
(fwiw, this is a breaking change for those who are consuming it directly. as it's undocumented, they shouldn't be.)
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.
So should i remove the arguments check from enableTimeouts?
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.
sorry to confuse; no, please leave it. I don't have any evidence this is used directly.
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.
(looks like you'll need to revert)
8a12604
to
adb3503
Compare
I've updated the PR to fix the jsdoc issue and remove the arguments check from |
adb3503
to
d959907
Compare
I've reverted removing the |
@makepanic thanks! |
Description of the Change
This PR adds missing argument checks and adds a couple getters to some of the main classes.
Should fix #3058.
If there are additional getters that I've missed, I can add them.