-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
Return new assertion with flags copied over instead of this. Fix #791 #799
Merged
lucasfcosta
merged 6 commits into
chaijs:master
from
vieiralucas:consistency-return-new-assertion
Sep 19, 2016
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4101fdf
Return new assertion instead of this for overwriteProperty
vieiralucas 4501970
Return new assertion instead of this for overwriteMethod
vieiralucas 27f4265
Return new assertion instead of this for addChainableMethod
vieiralucas f6c4fa3
Remove new methods and properties after using them for test
vieiralucas 1ae0a41
Return new assertion instead of this for overwriteChainableMethod
vieiralucas 5d11228
Wrap some utilities tests with describe so we can cleanup in an after…
vieiralucas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ | |
* MIT Licensed | ||
*/ | ||
|
||
var chai = require('../../chai'); | ||
var flag = require('./flag'); | ||
var transferFlags = require('./transferFlags'); | ||
|
||
/** | ||
* ### overwriteProperty (ctx, name, fn) | ||
|
@@ -58,7 +60,13 @@ module.exports = function (ctx, name, getter) { | |
var result = getter(_super).call(this); | ||
flag(this, 'keep_ssfi', false); | ||
|
||
return result === undefined ? this : result; | ||
if (result !== undefined) { | ||
return result; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's put braces around this. |
||
} | ||
|
||
var newAssertion = new chai.Assertion(); | ||
transferFlags(this, newAssertion); | ||
return newAssertion; | ||
} | ||
, configurable: true | ||
}); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does this create a circular dependency? Have we done this before? I feel like this might create issues
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.
Currently
addMethod
andaddProperty
have this too and there's been no issue reported about it. However, I'd like to have more time to check this before giving a confident response.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'm a bit confused how it's working.
test/bootstrap/index.js
requiresindex.js
index.js
requireslib/chai.js
lib/chai.js
requireslib/chai/utils/index.js
lib/chai/utils/index.js
requireslib/chai/utils/addProperty.js
lib/chai/utils/addProperty.js
requireslib/chai.js
Thus circular dependency. -scratches head-
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 it works because chai.js only sets
module.exports
and this file only calls stuff from chai.js inside of the methods, so it all kind of works out eventually.