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

normalize getters and setters (fixes #3058) #3064

Merged
merged 1 commit into from Oct 27, 2017

Conversation

makepanic
Copy link
Contributor

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 89.86% when pulling 8a12604 on makepanic:issues/3058 into 9f204ba on mochajs:master.

@boneskull
Copy link
Member

@makepanic thanks

Copy link
Member

@boneskull boneskull left a 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') {
Copy link
Member

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

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've initially removed the ms check but tests were failing here.
I'm unsure if removing the ms check will introduce a breaking change.

Copy link
Member

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.

Copy link
Member

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.

Copy link

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) {
  ....
}

Copy link
Member

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.

Copy link

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.
Copy link
Member

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?

@boneskull boneskull added the semver-minor implementation requires increase of "minor" version number; "features" label Oct 10, 2017
lib/context.js Outdated
*
* @api private
* @param {boolean} enabled
* @return {Context} self
*/
Context.prototype.enableTimeouts = function (enabled) {
if (!arguments.length) {
Copy link
Member

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.)

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

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)

@makepanic
Copy link
Contributor Author

I've updated the PR to fix the jsdoc issue and remove the arguments check from enableTimeouts.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 89.85% when pulling adb3503 on makepanic:issues/3058 into 9f204ba on mochajs:master.

@makepanic
Copy link
Contributor Author

I've reverted removing the enableTimeouts getter and left the Runnable.slow ms check in.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 89.869% when pulling d959907 on makepanic:issues/3058 into da901da on mochajs:master.

@boneskull
Copy link
Member

@makepanic thanks!

@boneskull boneskull merged commit 2303c66 into mochajs:master Oct 27, 2017
@boneskull boneskull added this to the v4.1.0 milestone Dec 29, 2017
@boneskull boneskull added the type: feature enhancement proposal label Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor implementation requires increase of "minor" version number; "features" type: feature enhancement proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

normalize setters and getters
4 participants