jedireza/aqua

verify a stub was called?

Closed this issue · 1 comments

is there any way with Lab/Code/Proxyquire to verify that a stub was called rather than the way I have done below ? want to avoid Sinon if I can

'use strict';

const Code = require('code');
const Lab = require('lab');
const Proxyquire = require('proxyquire');

const lab = exports.lab = Lab.script();


const NodeCronStub = {
    called : false,

    schedule : function (cronExpression, callback){

        this.called = true;
        console.log('dummy schedule');

    }

};

const LookerServiceStub = {
    called : false,
    getLookerReport : function (callback){

        this.called = true;
        callback(null,[{ foo: 'bar' }]);

    }
};

This sounds like it falls outside the scope of this project. The short answer is there are a few ways to accomplish your goals. 😄

Here's an example of finishing a test when a stub is called:

stub.Actions.login = function () {
done();
};

I found a relevant issue in the code repo issues here:
hapijs/code#66

Which led me to find a library some hapi contributors created called stand-in:
https://github.com/continuationlabs/stand-in

I hope this helps. Happy hunting.