Skip to content

Instantly share code, notes, and snippets.

@johanlunds
Created May 29, 2013 14:13
Show Gist options
  • Save johanlunds/5670559 to your computer and use it in GitHub Desktop.
Save johanlunds/5670559 to your computer and use it in GitHub Desktop.
it("should receive a successful response", function() {
spyOn($, "ajax").andCallFake(function(e) {
e.success({});
});
var callbacks = {
checkForInformation : jasmine.createSpy(),
displayCorrectMessagesAfterAjaxCallsComplete : jasmine.createSpy(),
retryRequest : jasmine.createSpy()
};
sendRequest(callbacks, configuration);
expect(callbacks. checkForInformation).toHaveBeenCalled(); //Verifies this was called
expect(callbacks. retryRequest).toHaveBeenCalled(); //Verifies this was called
});
it("should call Ajax error", function() {
spyOn($, "ajax").andCallFake(function(e) {
e.error({});
});
var callbacks = {
displayCorrectMessagesAfterAjaxCallsComplete : jasmine.createSpy()
};
sendRequest(callbacks, configuration);
expect(callbacks.displayCorrectMessagesAfterAjaxCallsComplete).toHaveBeenCalled();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment