Is it possible to verify arguments with a callback. I'm thinking something like this:
var spy = sinon.spy(someObject, "method");
//json is an object with like 10 properties
spy.withArgs(function(json){
return 'undefined' !== typeof json.importantProp1 && 'undefined' !== typeof json.importantProp2;
});
Not with a callback. In order to verify arguments you can use spy.calledWith
and similar.
Yes, you can do that with a matcher:
spy.calledWithMatch(function(json){
return 'undefined' !== typeof json.importantProp1
&& 'undefined' !== typeof json.importantProp2;
});
It is also possible to create a matcher with sinon.match(function () {}))
and use it with spy.withArgs
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.