Skip to content

Instantly share code, notes, and snippets.

@edshadi
Created June 18, 2014 17:51
Show Gist options
  • Save edshadi/897d070e4d7f34089778 to your computer and use it in GitHub Desktop.
Save edshadi/897d070e4d7f34089778 to your computer and use it in GitHub Desktop.
var mockAjax = function() {
beforeEach(function() {
jasmine.Ajax.install();
})
afterEach(function() {
jasmine.Ajax.uninstall();
})
}
var lastRequest = function() {
return jasmine.Ajax.requests.mostRecent();
}
var respondWithSuccess = function() {
lastRequest().response({
"status": 200,
"contentType": "text./plain"
});
}
var respondWithError = function() {
lastRequest().response({
"status": 500,
"contentType": "text./plain"
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment