Stubbing Accounts._hashLoginToken


#1

I am using Jasmine BDD framework and would like to server-unit-test my method which returns user by his login token. This method calls Account._hashLoginToken, which needs to be stubbed, but when I try to do:

describe('method `getUserByToken`', function () {
  beforeEach(function () {
    Accounts._hashLoginToken = emptyFn;
    console.log(JSON.stringify(Accounts, null, 2));
    spyOn(Accounts, '_hashLoginToken').and.returnValue(true);
  });
};

it outputs to the server console:

{
  "urls": {},
  "emailTemplates": {
    "from": "Meteor Accounts <no-reply@meteor.com>",
    "siteName": "localhost:3000",
    "resetPassword": {},
    "verifyEmail": {},
    "enrollAccount": {}
  },
  "loginServiceConfiguration": {}
}

as you see _hashLoginToken is not included. Html-reporter in Velocity test framework shows error:

TypeError: Object [object Object] has no method '_hashLoginToken'

pointing to source code of my Meteor method.

What I am doing wrong?