¡@

Home 

2014/10/16 ¤W¤È 12:08:55

jquery Programming Glossary: spyon

How to test the done and fail Deferred Object by using jasmine

http://stackoverflow.com/questions/12080087/how-to-test-the-done-and-fail-deferred-object-by-using-jasmine

this return this beforeEach function submitFormSpy spyOn backendController 'submitForm' .andCallFake fakeFunction describe.. 'if the message is empty' function beforeEach function spyOn backendController 'submitForm' .andCallThrough replace with.. replace with wherever your callbacks are defined spyOn this 'onSuccess' spyOn this 'onFailure' this.view. el.find '#message'..

How to properly unit test jQuery's .ajax() promises using Jasmine and/or Sinon?

http://stackoverflow.com/questions/13148356/how-to-properly-unit-test-jquerys-ajax-promises-using-jasmine-and-or-sinon

promise and resolve it according to your case. For example spyOn 'ajax' .andCallFake function req var d .Deferred d.resolve data_you_expect.. data_you_expect return d.promise for a success or spyOn 'ajax' .andCallFake function req var d .Deferred d.reject fail_result..

How do I verify jQuery AJAX events with Jasmine?

http://stackoverflow.com/questions/4662641/how-do-i-verify-jquery-ajax-events-with-jasmine

it should make an AJAX request to the correct URL function spyOn ajax getProduct 123 expect .ajax.mostRecentCall.args 0 url .toEqual.. should execute the callback function on success function spyOn ajax .andCallFake function options options.success var callback..

How to test the done and fail Deferred Object by using jasmine

http://stackoverflow.com/questions/12080087/how-to-test-the-done-and-fail-deferred-object-by-using-jasmine

this.done function return this this.fail function return this return this beforeEach function submitFormSpy spyOn backendController 'submitForm' .andCallFake fakeFunction describe 'if the message is empty' function beforeEach function.. button handler fired' function jasmine.Ajax.useMock describe 'if the message is empty' function beforeEach function spyOn backendController 'submitForm' .andCallThrough replace with wherever your callbacks are defined spyOn this 'onSuccess' spyOn.. function spyOn backendController 'submitForm' .andCallThrough replace with wherever your callbacks are defined spyOn this 'onSuccess' spyOn this 'onFailure' this.view. el.find '#message' .text '' this.view. el.find 'form' .submit it 'backendController.submitForm..

How to properly unit test jQuery's .ajax() promises using Jasmine and/or Sinon?

http://stackoverflow.com/questions/13148356/how-to-properly-unit-test-jquerys-ajax-promises-using-jasmine-and-or-sinon

It is not that complex actually. It suffices to return a promise and resolve it according to your case. For example spyOn 'ajax' .andCallFake function req var d .Deferred d.resolve data_you_expect return d.promise for a success or spyOn 'ajax'.. spyOn 'ajax' .andCallFake function req var d .Deferred d.resolve data_you_expect return d.promise for a success or spyOn 'ajax' .andCallFake function req var d .Deferred d.reject fail_result return d.promise for a failure. share improve this..

How do I verify jQuery AJAX events with Jasmine?

http://stackoverflow.com/questions/4662641/how-do-i-verify-jquery-ajax-events-with-jasmine

that the faked AJAX request was going to the correct URL it should make an AJAX request to the correct URL function spyOn ajax getProduct 123 expect .ajax.mostRecentCall.args 0 url .toEqual products 123 function getProduct id .ajax type GET url.. was executed upon an AJAX request completing successfully it should execute the callback function on success function spyOn ajax .andCallFake function options options.success var callback jasmine.createSpy getProduct 123 callback expect callback..