-
-
Notifications
You must be signed in to change notification settings - Fork 768
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
Make object "has" matcher recursive #1422
Make object "has" matcher recursive #1422
Conversation
I can see how this simplifies the notation when testing details in large objects. However, there is already a way to do the same thing, and I'm not sure if @sinonjs/sinon-core wants to introduce an alternative. sinon.assert.calledWith(spy, sinon.match.has("author", sinon.match.has("name", "cj"))); Also, consider using sinon.assert.calledWithMatch(spy, {
author: sinon.match.has("name", "cj")
}); |
@mantoni: Thanks for hint, I did not know about the functionality already existed (actually tried that composition way first, but because of my mistake it did not work - I like the composition more in fact). One of the reasons (apart of me trying to match stuff on serialised string instead of real object) why I did not know the feature is already present is that I did not find unit test nor documentation for it, so I have added both. Also reverted my original changes. |
@mareq Nice, thank you! You've added the documentation specifically for the v17 release. Can you add the documentation changes also to |
0d9c367
to
a0115f8
Compare
@mantoni Done: amended my last commit to move it from v17 to |
a0115f8
to
13b93e1
Compare
Thank you! |
Purpose (TL;DR)
Enable matching properties of embedded objects using
sinon.match.has
matcher.Background (Problem in detail)
Solution
createPropertyMatcher
has been modified such that:"dot.separated.embedded.property"
is checked using recursive helper functiondeepEqual
is run only on the value of the requested property, not on the whole top-level objectHow to verify - mandatory
npm install
npm test
(test case for the new functionality has been added)