testing - How to test a meteor method that relies on Meteor.user() -


i trying determine best way test code , running complications every direction i've tried.

the basic code (though far more complex due several layers of "triggers" implement this):

  1. client populates object
  2. client calls meteor method , passes object
  3. meteor method uses meteor.user() current user, adds "createdby" attribute object, inserts object , creates object (of different type) various attributes depend on first object, bunch of other things in database

i'm trying use velocity , jasmine. i'd prefer integration test these steps create first object , test second object created.

my problem if on server, meteor.user() call doesn't work. if on client, need subscribe large number of collections in order logic work, seems kludgy.

is there better approach? there way simulate or mock user login in server integration test?

in jasmine test can mock call meteor.user() so:

spyon(meteor, "user").and.callfake(function() {     return 1234; // user id }); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -