Skip to content

Add match.every and match.some (#1624) - #1661

Merged
mroderick merged 4 commits into
sinonjs:masterfrom
nivsherf:matchOnEveryElement
Jan 21, 2018
Merged

mroderick merged 4 commits into
sinonjs:masterfrom
nivsherf:matchOnEveryElement

Conversation

@nivsherf

@nivsherf nivsherf commented Jan 16, 2018 •

Copy link
Copy Markdown
Contributor

Add match.every and match.some as requested in issue #1624.

Steps to verify:

  1. npm install
  2. npm test

Added new matcher - match.every, which matches on an object or
iterable if all of the properties (or elements, respectively) match
the given predicate.
Added new matcher - match.some, which matches on an object or
iterable if some of the properties (or elements, respectively) match
the given predicate.

@mroderick mroderick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very nice pull request!

For the code, I only have the one comment about preferring refute over assert.isFalse.

Would you mind adding documentation for the new methods?

There's docs/CONTRIBUTING.md to get you started on the right foot.

Comment thread test/match-test.js Outdated
it("fails to match anything that is not an object or an iterable", function () {
var every = sinonMatch.every(sinonMatch.any);

assert.isFalse(every.test(1));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using assert.isFalse, you can use refute... you just have to import it from referee at the top of the file.

@nivsherf

Copy link
Copy Markdown
Contributor Author

Thanks for your feedback @mroderick. Edited the tests and added documentation for the new matchers.

@mroderick
mroderick merged commit c5dfaae into sinonjs:master Jan 21, 2018
@mroderick

Copy link
Copy Markdown
Member

This has caused tests in IE11 for master to fail. I am investigating. Once we have figured out what the error is caused by, I'll push a fix and we can get this shipped.

@mroderick

Copy link
Copy Markdown
Member

@mroderick mroderick added the semver:minor changes will cause a new minor version label Jan 21, 2018
@mroderick

Copy link
Copy Markdown
Member

This has been released as sinon@4.2.0.

@mroderick mroderick mentioned this pull request Jan 21, 2018
mroderick added a commit to mroderick/sinon that referenced this pull request Jan 21, 2018
This would have prevented the failing build in master that occurred
after merging sinonjs#1661, which would have allowed the author to fix it.
mantoni pushed a commit that referenced this pull request Jan 21, 2018
This would have prevented the failing build in master that occurred
after merging #1661, which would have allowed the author to fix it.
franck-romano pushed a commit to franck-romano/sinon that referenced this pull request Oct 1, 2019
* Add match.every (sinonjs#1624)

Added new matcher - match.every, which matches on an object or
iterable if all of the properties (or elements, respectively) match
the given predicate.

* Add match.some (sinonjs#1624)

Added new matcher - match.some, which matches on an object or
iterable if some of the properties (or elements, respectively) match
the given predicate.
franck-romano pushed a commit to franck-romano/sinon that referenced this pull request Oct 1, 2019
This would have prevented the failing build in master that occurred
after merging sinonjs#1661, which would have allowed the author to fix it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:minor changes will cause a new minor version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants