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):
- client populates object
- client calls meteor method , passes object
- 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
Post a Comment