Changeset 19:ab5f65372038 in pyenvjasmine for pyenvjasmine/envjasmine/specs/ajaxDemo.spec.js
- Timestamp:
- Apr 24, 2015, 1:03:31 PM (9 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pyenvjasmine/envjasmine/specs/ajaxDemo.spec.js
r0 r19 1 // Load the file to test here.2 //3 // Example:4 1 EnvJasmine.load(EnvJasmine.jsDir + "ajaxDemo.js"); 5 2 6 // This is the test code. 7 describe("AjaxDemo", function () { 8 it("calls the addDataToDOM function on success", function () { 9 TwitterWidget.makeRequest(); // Make the AJAX call 10 11 spyOn(TwitterWidget, "addDataToDOM"); // Add a spy to the callback 12 13 mostRecentAjaxRequest().response({status: 200, responseText: "foo"}); // Mock the response 14 15 expect(TwitterWidget.addDataToDOM).toHaveBeenCalledWith("foo"); 3 describe('greetUser', function () { 4 it('calls greeter on success', function () { 5 NS.greetUser(1); 6 spyOn(NS, 'greeter'); 7 mostRecentAjaxRequest().response({ 8 status: 200, 9 responseText: {"name":"Trevor"} 10 }); 11 expect(NS.greeter).toHaveBeenCalledWith('Trevor'); 16 12 }); 17 13 });
Note:
See TracChangeset
for help on using the changeset viewer.