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

.lengthOf should work for sets and maps #1110

Closed
rijnhard opened this issue Dec 18, 2017 · 9 comments
Closed

.lengthOf should work for sets and maps #1110

rijnhard opened this issue Dec 18, 2017 · 9 comments

Comments

@rijnhard
Copy link

sets and maps use a different property .size for their length but in the context of chai it should work the same way.

expect(new Set([1])).to.have.lengthOf(1);
// currently UncaughtException AssertionError: expected {} to have property 'length'
@rijnhard
Copy link
Author

workaround is:

expect(new Set([1])).to.have.property('size', 1);

@lucasfcosta
Copy link
Member

I think this is a very valid suggestion.

If other maintainers agree, I'd love to get this into our codebase.

Btw, this is very similar to #1096.

@meeber
Copy link
Contributor

meeber commented Jan 7, 2018

Agreed. May also be worth adding .size as an alias to .lengthOf.

@keithamus
Copy link
Member

keithamus commented Jan 8, 2018

PRs welcome for this! Let me know if anyone planning to make a PR would like some assistance

@asbish
Copy link
Contributor

asbish commented Jan 22, 2018

@keithamus I would like to do it by this weekend. Fine with you?

@keithamus
Copy link
Member

@asbish that would be more than fine. That would be wonderful!

@keithamus
Copy link
Member

@asbish I have assigned this to myself, and removed the pull-request-wanted label - this is so that you have time to make this PR without any one thinking it is free to work on. However, there is no pressure! If you decide you dont or cant work on it any more please let me know 😄

@asbish
Copy link
Contributor

asbish commented Jan 22, 2018

@keithamus Thank you for your kinds words! :)

@keithamus
Copy link
Member

hey @rijnhard thanks for this issue!

We're adding this in chai 5, we've added this to our Roadmap https://github.com/chaijs/chai/projects/2! We'll be releasing chai 5 soon, but for now I'll close this issue because it is tracked on our roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants