I have the file upload POST point in my Hapi.Js server. Here is code:
server.route([{
method: 'PUT',
path: '/upload/{id}',
config: {
handler: function(req,res) {
async.waterfall([
function checkEntityInDbExists(req.params.id,callback) {
...
callback(null, entityId);
},
function uploadPictureToAWS(entityId, callback) {
...
callback(null, imageLink);
},
function savePictureLinkInDbEntity(entityId, callback) {
...
callback(null, imageLink);
}
], function(err, result) {
if (err) {
return reply(err);
}
return reply(result);
});
}
}
}]);
How correctly cover the case "should return the uploaded image path" for this code/point without hitting DB and AWS?