-
-
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
.lengthOf for Maps and Sets #1131
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1131 +/- ##
=========================================
+ Coverage 93.69% 93.79% +0.1%
=========================================
Files 32 32
Lines 1649 1676 +27
Branches 396 404 +8
=========================================
+ Hits 1545 1572 +27
Misses 104 104
Continue to review full report at Codecov.
|
@asbish Oh nooo we've been foiled again by pizza. Thanks so much for working on this. It's going to be awhile until I can review; working crazy hours this week and then going on vacay next week. I'll try to carve out some time. |
bbdc3e1
to
644ac0b
Compare
644ac0b
to
6b7d6cc
Compare
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.
@asbish The code and tests look excellent to me. I appreciate your thoroughness.
I added a couple of inline comments regarding the docs for .lengthOf
.
Also, we should update the docs for the other assertions. For example, lines 1105-1106 could be updated to say "Add .lengthOf
earlier in the chain to assert that the target's length
or size
is greater than the given number n
." (It's probably overkill to say "the value of" and "property". It's probably also overkill to explicitly state that size
is for Map
and Set
. But I don't feel strongly about either of those statements.)
Finally, we should update the docs for assert.lengthOf.
lib/chai/core/assertions.js
Outdated
@@ -2013,6 +2048,11 @@ module.exports = function (chai, _) { | |||
* expect([1, 2, 3]).to.have.lengthOf(3); | |||
* expect('foo').to.have.lengthOf(3); | |||
* | |||
* When the target is a map or set, asserts that the target's `size` property. |
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 reads awkwardly to me. Instead of having this separate line, I suggest updating lines 2045-2046 to read: "Asserts that the target's length
or size
is equal to the given number n
."
And then the new examples could go right beneath the "foo" example.
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.
Thanks!
lib/chai/core/assertions.js
Outdated
* When the target is a map or set, asserts that the target's `size` property. | ||
* | ||
* expect(new Set([1, 2])).to.hove.lengthOf(2); | ||
* expect(new Map([['a', 1], ['b', 2]])).to.hove.lengthOf(2); |
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.
There's a typo in these examples: "hove" instead of "have".
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.
Thanks!
51d9761
to
7ec14ad
Compare
@meeber Thank you so mush for your review! |
LGTM! Looking for second review from @chaijs/chai |
As described in #1110, this PR adds support for Map and Set to .lengthOf and chains such as .above, .below, .least, .most and .within.
I have not added alias 'size' to .lengthOf this time so as not to fix some exist test cases (Levenshtein distance between 'size' and 'pizza' used in the test cases is close). Will you give me some feedback on the above?
Feel free to point out possible mistakes. Thanks!