I have a javascript function deleteSomething()
, within which the load() function in jQuery is called.
function deleteSomething(a, b){
deleteIt(a, b, function(success){
if(success){
$("#table").load(...);
}
})
}
Now I want to test deleteSomething()
with Jasmine to see if load() is being called. But got Error: Expected a spy, but got Function
describe("deleteSomething", function() {
beforeEach(function () {
...
});
it("should call load() when deleteIt returns true", function() {
spyOn($('#table'), 'load'));
deleteIt.and.callFake(function(a, b, callback){
callback(true);
});
deleteSomething(a, b);
expect($('#table').load).toHaveBeenCalled();
});
});
I'm new to Jasmine, how should I do this?