-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
test(assert): increase coverage #1085
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1085 +/- ##
==========================================
+ Coverage 93.61% 94.34% +0.73%
==========================================
Files 32 32
Lines 1628 1628
Branches 393 393
==========================================
+ Hits 1524 1536 +12
+ Misses 104 92 -12
Continue to review full report at Codecov.
|
Since the Seems doesNotIncrease do it correctly. Since the author of #621 is @lucasfcosta, i like to listen to his opinion as well. |
lib/chai/interface/assert.js
Outdated
* Can be used to assert the inclusion of a subset of properties in an | ||
* | ||
* Asserts that 'haystack' includes 'needle'. | ||
* Can be used to assert the inclusion of a subset of properties in an |
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.
trailing space are removed by atom i guest. Would this affect documentation? If yes i will carefully add space on every
next line. So next line will be *<space><space>...
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.
Well, I would not worry about this that much even though we've already got #1042.
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.
Alright, the overall explanation make it clearer. I will process when i had chance 😄 , glad to see you back. 💌
test/assert.js
Outdated
assert.changesButNotBy(fnDec, obj, 'value', 1); | ||
// assert.changesButNotBy(fnDec, getterFn, 'value', 1); |
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.
Why are these assertions commented out? Do they not work?
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.
Yes Cap, it doesn't work. That's why i made #1090 , 😄
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.
Hi @brutalcrozt,
First of all, I'd like to thank you for this PR! ❤️
However, I don't think these changes are compatible with our intentions with the changes
/increases
/decreases
API.
There has been a misunderstanding.
As I've commented in my review, when providing a prop
and a function we will end up checking for that prop
in the function
object. This is how the API is supposed to work.
If we've already got a getterFn
then we don't need to specify any keys and it would not allow us to check for properties in functions.
lib/chai/interface/assert.js
Outdated
msg = tmpMsg; | ||
prop = null; |
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 this is not correct.
When we have four arguments and the type of obj
is a function, we cannot set prop
to null because the user might desire to check for the value of a prop
in a function
, since a function
in JavaScript can have properties.
Please correct me if I'm wrong.
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 will try to exclude this commit, focusing on testing only. Either we both wrong or none of us is wrong.
lib/chai/interface/assert.js
Outdated
delta = prop; | ||
msg = tmpMsg; | ||
msg = 'getter function'; | ||
prop= null; |
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.
Same here, if we have four arguments to this I think that prop
must not be null
.
Also, a space is missing between prop
and the =
sign.
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.
OMG, he notice 😄 , indeed that's my mistake. Did we need eslint?
lib/chai/interface/assert.js
Outdated
* Can be used to assert the inclusion of a subset of properties in an | ||
* | ||
* Asserts that 'haystack' includes 'needle'. | ||
* Can be used to assert the inclusion of a subset of properties in an |
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.
Well, I would not worry about this that much even though we've already got #1042.
test/assert.js
Outdated
bangFn = function() { obj.str += '!' }, | ||
smFn = function() { 'foo' + 'bar' }, | ||
batFn = function() { heroes.push('batman') }, | ||
lenFn = function() { return heroes.length }; | ||
|
||
assert.changes(fn, obj, 'value'); | ||
assert.changes(fn, getterFn, 'value'); |
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 also think that this is incorrect.
When writing assert.changes(fn, getterFn, 'value')
I understand that you expect fn
to change the property value
of getterFn
.
It's redundant to specify a key
if you already have a getter function. If we did this it would not be possible to check for property in function
objects as well.
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 the misunderstanding is located here.
I found it awkward when we use assert(fn, getterFn, null, 1);
Which should be assert.changesBy(fn, getterFn, deltaValue);
I will continue discussing on issue 1090, kindly re-validate with your point of view.
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.
Hi @brutalcrozt, thanks for the answer.
I'm sorry but I still didn't understand how this could be correct, since delta
cannot be a string
, which is what you're passing by using 'value'
as the last argument.
Can anyone else please review & confirm just for us to make sure we're not missing any detail?
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.
Hey brother, i think no need to ask third person point of view. I assume there is misunderstanding, i can say it correct just because run node test resulting green and travis also green. Have i show you this ?
Sorry i also make mistake again here, i mislead you. you are reviewing the assert.changes
but i am comment about assert.changesBy
.
I think that assert.changes
pass because the key or property is be null when reaching this line.
do i need make additional change about this assert.changes
?
If you don't mind, please addressing assert.changesBy
on other line. When you feel still necessary 😄 .
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.
Ah, I understand this now. You were right about the tests passing.
The reason why I was confused was because of this line, which uses the third argument as a message when the second one is a function
and we only have three arguments.
However, would you mind just changing the value
string to example message
or something like that? Just to make sure the test looks clear.
Great work, btw! Thanks 😄
PS.: IMO we should change this API in the future, otherwise we will make it mandatory for users to supply a message when they want to assert on a property
present in a function, which is not that uncommon.
What do you think?
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.
Done, let me know if this still require some change.
Agreed, we should add it to next milestone. 4.2.0 ?
Kinda related to #1090, but unfortunately i still have issue to formulate the word. Let's continue there 😉
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.
Hi @brutalcrozt, thanks for the new commits, but I've seen that you just added a revert commit to this PR, but doing so basically resets all the feature changes right? Right now we've only got test changes.
I've seen the diff and the tests look a bit confusing btw. I made specific comments on them.
Let's make sure all the code is correctly indented too.
When reverting changes I highly recommend you to use rebase
instead of adding commits. Rebase allows you to make the git log look cleaner and better without adding new unnecessary commits.
This video is a great way to learn about rebase
btw.
If you need any help, please let me know.
test/assert.js
Outdated
@@ -2251,26 +2251,33 @@ describe('assert', function () { | |||
heroes = ['spiderman', 'superman'], | |||
fn = function() { obj.value += 5 }, | |||
fnDec = function() { obj.value -= 20 }, | |||
getterFn = function() { return obj.value }, | |||
getter= function() {}, |
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.
Missing a space between =
and the identifier.
test/assert.js
Outdated
bangFn = function() { obj.str += '!' }, | ||
smFn = function() { 'foo' + 'bar' }, | ||
batFn = function() { heroes.push('batman') }, | ||
lenFn = function() { return heroes.length }; | ||
|
||
getter.value= obj.value; |
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.
Missing a space here too. But this line will probably end up being deleted due to never using getter
.
test/assert.js
Outdated
@@ -2251,26 +2251,33 @@ describe('assert', function () { | |||
heroes = ['spiderman', 'superman'], | |||
fn = function() { obj.value += 5 }, | |||
fnDec = function() { obj.value -= 20 }, | |||
getterFn = function() { return obj.value }, | |||
getter= function() {}, |
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.
It also seems like this function is never used.
test/assert.js
Outdated
assert.changes(fn, obj, 'value'); | ||
assert.changes(fn, getterFn, 'value'); |
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 does not seem correct.
If we want to test properties on functions we must create an fn
that changes the value of a prop in the getterFn
. What you've done here is create another getter
function which has a value
prop that is never used.
test/assert.js
Outdated
assert.changesBy(fn, obj, 'value', 5); | ||
assert.changesBy(fn, obj, 'value', -5); | ||
assert.changesBy(fn, getterFn, 5); |
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.
Please take a look at the comment I've made on the first assertion test because that is valid to all additions below, such as this one.
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 basically resets all the feature changes right?
Yes, sir.
Let's make sure all the code is correctly indented too.
Agreed.
Sorry that i have made unnecessary notification and work for you. I already take a look at your slack status about 5-10 min, because i already had bad experience with git rebase
. So i ask Keith instead, but still i get lost on my own confusion. With your aid i found some clarity, but it seems i found it while you do the last review.
Due to unexpected rain, i made those dirty line. I have to save really quick and forgot to clean up, i will make sure it won't happen again. I will watch video that you mention, when i get lost again about git rebase
.1. I am also not sure are you still busy on real world or not 2. Based on previous response time, i assume that this PR will get a bit of delay. Somehow i miss your last review on this PR.
I really felt bad about this, hope on tomorrow. It should bring fresh state.
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.
Hey buddy, there's no need to feel bad about it. We're very happy that you want to contribute. Please don't worry about that 😃
Basically, when doing a rebase -i
you will be prompted with a list of commits and a few actions to do with them.
Whenever you want to drop a commit you can just use the drop
word in front of it.
In order to ammend a commit into the last one you can use fixup
and you can also use squash
to ammend commits and change their messages as well.
After doing it a few times you will see it's simple, you just gotta try, it's totally normal to make mistakes the first times you try it.
d3d5b24
to
13283b3
Compare
I got it now, I just had a minor comment about the Also, IMO we should change this API in the future to make it more consistent. I think that checking Right now we need to pass a |
567ff6d
to
36a455d
Compare
😄 ahh a burst of happiness. Finally i got the point of rebase, also i can address my own misunderstanding. I got minor curiosity, kindly someone answer it:
|
@brutalcrozt I'm afraid I won't be able to help regarding that since I don't use the web interface. I'm also not sure I understand your question correctly. But please make sure to check your |
Nvm, the question is not really important. |
@brutalcrozt please try this: https://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit |
36a455d
to
7699a26
Compare
Okay, now it's green? 😍 . Thanks for believe in me. |
Yay! You're almost there buddy, you just gotta change the commit message following these guidelines: https://conventionalcommits.org/ |
- on changes, decreases and increases family
7699a26
to
6eb1a50
Compare
done |
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.
Awesome work @brutalcrozt and @lucasfcosta. This LGTM.
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.
Nice work! Will let @lucasfcosta review and merge if he's happy :)
@lucasfcosta Any chance you could take a look at this? You have an open review blocking merge :D |
Oh, I'm so sorry I missed this for so long! |
related issue #1084