Currently, I am running a code test with Jasmine and setting up a mock object for the ajax method.
spyOn($,'ajax').and.callFake(function(e){
console.log("is hitting");
})
In order to test the code snippet below:
$.ajax({
url: AppManager.defaults.contextPath + "/solutions/mcn/mcn-lookup-list",
data: {
mcnNumber : mcnNumberData,
mcnCustomerName : mcnCustomerNameData
},
dataType: "json",
type: "GET",
global: false
})
.done(function(data) {
solution.CommonObjects.theSolution.orderHandoff.mcnSearchData = self.filterMCNSearchData(data, resultObj);
$promise.resolve();
})
.fail(function() {
$promise.reject();
self.displayErrorPopup('MCN Search Error','There is no MCN associated with MCN Number or MCN Customer Name Entered!!!');
});
},
An error is being thrown: "cannot read done of undefined". Do I also need to create a spy for that? Can you please provide assistance with the code for that?