meteor-velocity / velocity-helpers

Testing helpers for Meteor apps to make common testing tasks straight forward.
MIT License
7 stars 0 forks source link

Mock one specific Meteor method #3

Closed ghost closed 9 years ago

ghost commented 9 years ago
spyOnMethod('myMeteorMethod').and.returnValue('result');

should be available and not affect other Meteor methods.

ghost commented 9 years ago

Here is how I do this without sugar:

var call = Meteor.call;
// data is the argument of the method we mock
spyOn(Meteor, 'call').and.callFake(function (method, data, callback) {
  if (method === 'myMeteorMethod') {
    callback(null, 'result');
  } else {
    call.apply(Meteor, arguments);
  }
});
ghost commented 9 years ago

Released with 0.1.0