Meteor / Jasmine / Velocity : how to test a server method requiring logged in user?

前端 未结 4 1722
萌比男神i
萌比男神i 2021-02-15 17:50

Using velocity/jasmine, I\'m a bit stuck on how I should test a server-side method requiring that there be a currently logged-in user. Is there a way to make Meteor think a user

4条回答
  •  长情又很酷
    2021-02-15 18:23

    What are you testing and why does it require a user to be logged in? Most of the methods I have that need a user object I pass the user object into. This allows me to call from a test without actually being logged in. So in the actual running of the code I would pass...

    var r = myMethod(Meteor.user());
    

    but when running from the test I would call like...

    it('should be truthy', function () {
      var r = myMethod({_id: '1', username: 'testUser', ...});
      expect(r).toBeTruthy();
    });
    

提交回复
热议问题