-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
withArgs(sinon.match()) doesn't use last defined return definition #1053
Comments
Thanks for reporting. I am unsure if this should be fixed in v1.17 in case anyone relies on this behavior, but a fix for this could be put into |
Yeah, since the behavior seem to be undocumented, there is no "fact" to base it on. In an ideal world, it would be even better if it would work like css selectors, meaning most detailed match would have precedence but I have no idea on how that would actually be implemented... |
"Most detailed" would be very hard, especially given javascript's dynamic typing and type conversion rules. If you could patch the basic case (the one submitted) then that would be a candidate for 2.0. |
@jishi : do you think you could supply us with a patch? seems you have a good idea on solving this. |
I can look into it. It should go in the master branch then? |
Help is always welcome. This might be related to #817. |
Hey @jishi, any chance of getting a PR for this issue? |
I haven't had time to look at it, but I'll free up some time before end of the week. |
Seemed easier than anticipated, made a pull request for review |
What did you expect to happen?
I would expect that the last withArgs return declaration to to have precedence when multiple declarations would match the invocation.
What actually happens
The first one seems to have precedence opposed to when you are using strict values instead of sinon.match
How to reproduce
Probably due to that "strict" declarations actually overwrite the withArgs precondition, and that is not possible with match-objects. However, if they were applied on the opposite order (last defined, first matched), it would match the normal behavior, I think.
The text was updated successfully, but these errors were encountered: