I have a module that I am trying to test. It is laid out like this:
exports.doThings = function(args, callback) {
async.series([
function doThisFirst(next) {....},
function doThisSecond(next) {....}
], .....
}
I would very much like to individually test the functions doThisFirst and doThisSecond, so I tried to export them like so:
exports.doThings = function(args, callback) {
async.series([
exports.doThisFirst = function(next) {....},
exports.doThisSecond = function(next) {....}
], .....
}
but alas, I get this error when I run the test: TypeError: Object # has no method 'doThisFirst'
It works if I change the code to this:
exports.doThings = function(args, callback) {
async.series([
exports.doThisFirst,
exports.doThisSecond
], .....
}
exports.doThisFirst = function(next) {....}
But I think that is bad for the code readability. Is there any way to get around this issue?