I am a newbie to javascript.I am trying to write a basic unit test using proxyquire. for below code.
file A:
const modA=require('./modA');
const modB=require('./modB');
const async=require('async');
module.exports=function(a,b,callback){
async.parallel([
function(callback){
// db call
modA(a,b,callback);
},
function(callback){
// db call
mobB(a,b,callback);
}
],
//not able to test code
(err,res){
//do something
});
};
Unit test for file A looks like below:
const proxyquire=require('proxyquire');
function modaAStub(a, b, callback) {
return (null, modAresponse);
}
function modaBStub(a, b, callback) {
return (null, modaBresponse);
}
describe('test suite', () => {
it('test: should return results', (done) => {
const fileA = proxyquire('../../fileA', {
'./modA': modaAStub,
'./modB': modaBStub
});
fileA(someinput1,someinput2);
done();
});
});
the problem is,I am unable to figure out how to test the piece of code in fileA which has '//do something'.
Appreciate any pointers/code.
Thanks.