I have a function inside my javascript file as follow:
`(function($){
"use strict";
$(document).ready(loadPics);
function loadPics(){
$.getJSON(formUrl(), function(data){
if (data) {
createDomElm(data);
}
});
}
})(jQuery);
the test from my spec.js look as follow:
QUnit.test("jQuery.getJSON should be called", function (assert) {
var spy = this.spy(jQuery, 'getJSON');
assert.ok(callCount('getJSON'));
sinon.assert.callCount(spy, 1);
});`
the function loadPics() containing the getJSON inside of my jQuery gets called. but when i try to get the callcount(spy, 1) it returns false; The only thing i am trying to test is how many getJSON calls are inside my JS, without making the functions available to my window object.
Aucun commentaire:
Enregistrer un commentaire