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 promise assertions #360

Closed
wants to merge 10 commits into from
Closed

Conversation

ariporad
Copy link
Contributor

Hi All,

Here's the fix for #309, It has a good number of tests, but let me know if there's anything I should change.

@@ -165,35 +172,49 @@ Test.prototype._end = function (err) {
Test.prototype.exit = function () {
var self = this;

// calculate total time spent in test
this.duration = globals.now() - this._timeStart;
function checkAssertLength() {
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'm not sure if this should be here, or it should be a method, or if it should be an external function which accepts self. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I would make it a private instance method (prefixed with _). The function checks if assertion count matches plan count. I think the name could be clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -25,11 +25,18 @@ function Test(title, fn) {

this.title = title || fnName(fn) || '[anonymous]';
this.fn = isGeneratorFn(fn) ? co.wrap(fn) : fn;
this.assertCount = 0;
this.assertPromises = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

assertPromises -> assertions

@jamestalmage
Copy link
Contributor

@ariporad - Good work! A few minor nits, but overall very well done!

@ariporad
Copy link
Contributor Author

@jamestalmage: Should be fixed now.

@ariporad
Copy link
Contributor Author

@jamestalmage: Hang on a second actually, delay doesn't like node@<4.0.0

@sindresorhus
Copy link
Member

delay doesn't like node@<4.0.0

It's node@<0.12, and just put global.Promise = require('bluebird'); at the top.

@ariporad
Copy link
Contributor Author

@sindresorhus: Yeah, I was trying to avoid that, but it's not that big a deal.

@@ -93,6 +93,7 @@
"core-assert": "^0.1.0",
"debug": "^2.2.0",
"deeper": "^2.1.0",
"delay": "^1.2.0",
Copy link
Member

Choose a reason for hiding this comment

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

This should be a dev dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@ariporad ariporad force-pushed the fix-promise-assertions branch 2 times, most recently from 2f67fb4 to c7b0154 Compare December 24, 2015 01:06

if (!this.ended) {
this.ended = true;
Test.prototype.exit = function () {

Copy link
Member

Choose a reason for hiding this comment

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

remove this empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sindresorhus: Fixed

@ariporad ariporad force-pushed the fix-promise-assertions branch from 75ca556 to 8a37069 Compare December 24, 2015 01:39
@ariporad
Copy link
Contributor Author

Ok, @jamestalmage, @sindresorhus: Everything should be fixed now.

@vadimdemedes
Copy link
Contributor

LGTM, great stuff!

@jamestalmage
Copy link
Contributor

Let's get sindresorhus/delay#8 merged and published. Then use the updated function here. Once that happens, I think we are good to go.

@ariporad ariporad force-pushed the fix-promise-assertions branch from 8a37069 to 149ceb3 Compare December 25, 2015 17:07
@ariporad
Copy link
Contributor Author

Ok, I just rebased onto master.

@sindresorhus
Copy link
Member

@ariporad [email protected] is now out. Can you update tests to use it? Other than that, this looks good to land.

@ariporad ariporad force-pushed the fix-promise-assertions branch from 149ceb3 to 0063076 Compare December 25, 2015 22:19
@ariporad
Copy link
Contributor Author

@sindresorhus: Ok. Fixed, and rebased onto master. Ready for merging.

@sindresorhus
Copy link
Member

Landed. Really dig this fix @ariporad :)

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.

4 participants