Tag: jasmine2.0

如何使用jasmine来模拟jquery getJSON回调

我有一个包含加载函数的模块,而load函数调用jQuery的getJSON函数 load(key,callback){ // validate inputs $.getJSON( this.data[key],”,function(d){ switch(key){ // do some stuff with the data based on the key } callback(‘success’); }); } 使用Jasmine 2.0如何模拟对getJSON的调用,但是将数据提供给匿名函数?