I'm using the superagent ajax library for an app, and I'm trying to write some unit tests for it. I've got a class which looks like this:
someClass = {
getData: function(){
_this = this;
superagent.get('/some_url').end(function(res){
if(res.body){
_this.data = res.body
}
});
});
}
How do I write a Jasmine test to spy on the _this.data = res.body
call? Setting up a spy with and.callThrough()
on getData
isn't working. I don't want to actually call the URL in question; I'm just trying to test that if it gets data, it does something with it.
Thanks