Skip to content

Instantly share code, notes, and snippets.

@shrop
Created June 23, 2015 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrop/536979155d253009db80 to your computer and use it in GitHub Desktop.
Save shrop/536979155d253009db80 to your computer and use it in GitHub Desktop.
logActivity Jasmine test
describe('logActivity server method', function() {
it('saves an activity document to the posts collection', function() {
// Get the testuser document.
testUser = Meteor.users.findOne( { 'profile.userName': 'testuser' } );
// Mock Meteor.userId().
spyOn(Meteor, 'userId').and.returnValue(testUser._id);
// Mock inserts for activity.
spyOn(Activity, 'insert');
type = 'post';
sourceId = '45B7E9XDWgm9ZKXdv';
Meteor.call('logActivity', type, sourceId);
expect(Activity.insert).toHaveBeenCalledWith({
type: 'post',
sourceId: '45B7E9XDWgm9ZKXdv',
userId: testUser._id,
timestamp: new Date()
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment