Skip to content

Instantly share code, notes, and snippets.

@dperrymorrow
Forked from gigasquid/mymethodTest.js
Created June 22, 2012 19:12
Show Gist options
  • Save dperrymorrow/2974575 to your computer and use it in GitHub Desktop.
Save dperrymorrow/2974575 to your computer and use it in GitHub Desktop.
Example Spec File for Ajax Mocking with Jasmine
describe("Mocking Ajax Calls", function() {
beforeEach(function() {
loadFixtures('test.html');
//mocking ajax call with Jasmine Spies
var fakeData = "You can put your return data here";
spyOn($, "ajax").andCallFake(function(params) {
params.success(fakeData);
});
});
it("Should have a Happy Face", function() {
mymethod();
expect($('#mydiv')).toHaveText("Happy Face");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment