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

Assert that a collection contains a value satisfying a condition #39

Open
radekn opened this issue Jan 28, 2016 · 2 comments
Open

Assert that a collection contains a value satisfying a condition #39

radekn opened this issue Jan 28, 2016 · 2 comments

Comments

@radekn
Copy link

radekn commented Jan 28, 2016

I stumbled once into a use case that seems not to be covered by must - to assert that a collection (object or array) contains a value satifsying a specific condition.

There is includes matcher, but it only checks for strict equality, so I couldn't use it. I think I ended up using Lodash to find the element, and then used exist matcher on the result. It worked well, but left me with the feeling that it would be much nicer (more concise and idiomatic) if I could do it directly with the assertion library.

Any thoughts?

@moll
Copy link
Owner

moll commented Jan 29, 2016

Hey!

You mean something like Array.prototype.some? I've thought of something like it, akin to the "middleware" thing that Must.prototype.then is — allow you to call foo.must.have.some.eql({name: "John"}) or equivalent.

@radekn
Copy link
Author

radekn commented Jan 29, 2016

Yes, having something like this would be awesome :)

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

No branches or pull requests

2 participants