Hi,
We are moving from mocha + sinon to jasmine, and I found some cases that look weird after replacing with jasmine.
For example, using sinon stubs I could do smth like this:
Backbone.ajax.yieldsTo('success', { success: true });
When stub will be called - success callback of passed object will be executed with { success: true } as a result.
In Jasmine it's possible to do like this:
this.Backbone.ajax.and.callFake(function(obj) {
obj.success({ success: true });
});
I view sources and found that also it's possible to do via extending SpyStrategy, like this:
beforeEach(function() {
jasmine.SpyStrategy.prototype.yieldsTo = function(prop, response) {
return this.callFake(function(obj) {
if (typeof obj[prop] === 'function') {
obj[prop](response);
}
});
};
});
But I am not sure about this - because it's not mentioned in official documentation.
It seems like an API to provide other spy methods based on core methods.
Could I rely on extending SpyStrategy or not?
Thank you.