I have a file with format below which uses certain module.
let module = require('modulename')
let r = module()
r.post(variable, callbackFunction)
r.post(variable, variable, variable, callbackFunction)
I am trying to mock this two function using proxyquire as given below
let module= function(){
return {
post: (variable, callback) => {
//some codes
return callback(error, res)},
post: (variable,variable,variable, callback) => {
//somecode
return callback(error, res)}
}}
let mock = proxyquire(filepath,{'modulename':module})
Since it contain two function with same name, i am unable to mock these two post function as the function call goes to only one function(second function). How to resolve this? Anyody got any idea? I am fairly new to unit testing and proxyquire