Testing: stubbing meteor.call

We’re trying to test the allow and deny rules of our collection, which make use of a Meteor.call to another collection file that is in the server folder. Because we want the test to be independent, we want to try and circumvent this Meteor.call. We thought about trying to stub the Meteor.call, but until now had no succes.

We’re using Mocha as our testing framework, where our test case looks like this now:

    it("Test insert", (done) => {
        var toInsert  = {
            message: 'test'
        };
        try {
            Col.insert(toInsert);
            done();
        } catch(err) {
            console.log(err);
        }
    });

Where the collection insert has the following allow rule:

    insert: function () {
        var hasPermission = Meteor.call('checkRights');
        return hasPermission;
    }

When we try to run this test without trying to stub, but then we encounter the problem that the collection that contains checkRights is only available on the server side and we are not able to stub it.

Now we are wondering if we are even taking the right approach to testing this or if there is something fundamentally wrong with putting the second collection inside the server folder?