Created
December 13, 2010 21:00
-
-
Save cjohansen/739597 to your computer and use it in GitHub Desktop.
Mocking jQuery.ajax with Sinon.JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("SinonMockJQAjaxWithJasmine", function() { | |
it("should mock a jQuery ajax request", sinon.test(function () { | |
this.mock(jQuery).expects("ajax").once(); | |
jQuery.ajax({ | |
url: "/something" | |
}); | |
})); | |
it("should fail when expectations are not met", sinon.test(function () { | |
this.mock(jQuery).expects("ajax").twice(); | |
jQuery.ajax({ | |
url: "/something" | |
}); | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment