javascript - Can't get $.ajax.mostRecentCall to work with jasmine 2.0.2 -


having real trouble getting simple example work. using example taken https://gist.github.com/madhuka/7854709

describe("test spies", function() {  function sendrequest(callbacks, configuration) {         $.ajax({             url: configuration.url,             datatype: "json",             success: function(data) {                 callbacks.checkforinformation(data);             },             error: function(data) {                 callbacks.displayerrormessage();             },             timeout: configuration.remainingcalltime         });     }      it("should make ajax request correct url", function() {      var configuration = {         url : "http://www.google.com",         remainingcalltime : 30000     };          spyon($, "ajax");          sendrequest(undefined, configuration);         expect($.ajax.mostrecentcall.args[0]["url"]).toequal(configuration.url);     }); }); 

for whatever reason, $.ajax.mostrecentcall undefined.

using jasmine 2.0.2 , jasmine jquery 2.0.5.

fiddle here: http://jsfiddle.net/sidouglas/85b35993/

this old 1.x jasmine syntax:

$.ajax.mostrecentcall.args 

the syntax jasmine 2 is:

$.ajax.calls.mostrecent().args 

so assertion should be:

expect($.ajax.calls.mostrecent().args[0]["url"]).toequal(configuration.url); 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -