Closed hargup closed 7 years ago
You had a list of affected test files, right? can you update the issue with those?
You had a list of affected test files, right? can you update the issue with those?
Updated, btw this should be easy to fix.
Thanks. It's not necessarily as straightforward. From what I remember, I had found RemoteBinaryFile.spec.js
to be a bit tricky.
I see, you delete several functions from Jasmine. But where to find them again? Test example is broken on SO: https://stackoverflow.com/questions/4662641/how-do-i-verify-jquery-ajax-events-with-jasmine/6199132#6199132
Is upgrade_to_2 guide is still actual?
For some reason it can be rewrited to hard-readable code:
window.getProduct = function getProduct (id, callback) {
$.ajax({
type: "GET",
url: "data.json",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: callback,
});
};
it("should make a real AJAX request", function (done) {
spyOn(window, 'getProduct').and.callThrough(); //create a spy
var callback = function() {
expect(getProduct).toHaveBeenCalled(); //use the spy instead of callback
done();
};
getProduct(123, callback);
});
P.S.: The old code was:
it("should make a real AJAX request", function () {
var callback = jasmine.createSpy();
getProduct(123, callback);
waitsFor(function () {
return callback.callCount > 0;
});
runs(function () {
expect(callback).toHaveBeenCalled();
});
});
function getProduct (id, callback) {
$.ajax({
type: "GET",
url: "data.json",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: callback,
});
}
Some of the js tests in the
master
fails with the errorReferenceError: waitsFor is not defined
. That is becausewaitsFor
1 which provides Asynchronous support in Jasmine 1.3 is now replaced by an new syntax 2 Here are the list of the files that needs a fix. I got them fromgit grep "waitsFor"