How to spy on collection helper methods

Hola

So I’m using sinon, chai as mentioned in the guide [and am testing/spying on many other things successfully]… and I have many helper methods (thanks to excellent dburles:collection-helpers) defined similar to below:

Meteor.users.helpers({
  doSomething() {
  },

Typically in my methods I’ll look up user and call helper Meteor.users.findOne(id).doSomething()

How do I test such a scenario? Tried the below options and nothing seems to work.

let something = sandbox.spy(Meteor.users._helpers.prototype, "doSomething") //looked at dburles:collection-helpers code to see where the helpers are defined but the expect(something).to.have.been.called fails
//
let something = sandbox.spy(Meteor.users, "doSomething") // fails
//
let user = Meteor.users.findOne(id)
let something = sandbox.spy(user, "doSomething") // fails as user = different instance of course

Any ideas how to resolve this please?

Thanks

The first way does actually work:

let spy = sandbox.spy(Meteor.users._helpers.prototype, "doSomething")

Turns out

expect(spy).to.have.been.called [… no brackets and works]

is not the same as

expect(spy).to.have.been.called() [… with brackets and fails]

But is this the best way?

To make my life easier for testing I have all my helpers as a separate class with static methods, rather than creating document objects with helpers on the prototype