mercredi 29 juillet 2015

Testing an async function with Jasmine in Meteor

I have looked at several other questions related to this on Stackoverflow, but I still can't seem to solve my problem. No matter what I seem to do, it seems that either Meteor.call doesn't get invoked, or if I can get it to be invoked (such as in the code sample below), no matter what the jasmine.DEFAULT_TIMEOUT_INTERVAL is set to, I continue to get the following error:

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

This is what my Jasmine test looks like:

it("Should be created and not assigned to anyone", function(done) {
    jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000000;

    // Confirm that the User Has Logged in
    expect(Meteor.userId()).not.toBeNull();

    var contact = null;
    var text = "This is a testing task";
    spyOn(Tasks, "insert");
    spyOn(Meteor, "call");

    Meteor.call('addTask', contact, text, function(error, result) {
      expect(error).toBeUndefined();
      expect(result).not.toBeNull();
      done();
    });

    expect(Meteor.call).toHaveBeenCalled();

  });

});

And my addTask function looks like this:

Meteor.methods({

  addTask: function (contact, text) {
     ... // addTask Code, removed for brevity
  },
});

Iv been stuck on this for weeks, any help anyone can provide would be super helpful.

Aucun commentaire:

Enregistrer un commentaire