karma-jasmine-ajax

How do I test a function that calls an AJAX function without firing it using jasmine?

六眼飞鱼酱① 提交于 2019-12-30 07:30:33
问题 I've checked in How do I verify jQuery AJAX events with Jasmine? and How to test an Angular controller with a function that makes an AJAX call without mocking the AJAX call? but for some reason they don't necessarily come out with a format that works for me. My issue is that I'm unit testing a function that makes a call to a function that fires off an AJAX request. I want to test the outer function without firing off the AJAX request (or halt that request) so I don't get a bunch of faulty

How do I test a function that calls an AJAX function without firing it using jasmine?

安稳与你 提交于 2019-12-01 01:12:19
I've checked in How do I verify jQuery AJAX events with Jasmine? and How to test an Angular controller with a function that makes an AJAX call without mocking the AJAX call? but for some reason they don't necessarily come out with a format that works for me. My issue is that I'm unit testing a function that makes a call to a function that fires off an AJAX request. I want to test the outer function without firing off the AJAX request (or halt that request) so I don't get a bunch of faulty data shot into the data server. Here is my outer function (which calls the function containing the AJAX):