I have two files inside my project:
controller.js
const controller = (request, response, route_name) => {
parser[route_name](request.query, request.body, (err, data) => {
...
}
};
export default controller;
parser.js
const parser = {
foo: (query, body, callback) => {
...
return callback(obj, null);
}
};
export default parser;
Now, I am currently trying to test my controller. The first test is to send a bad formatted request and except the parser to call the callback with certain arguments. I have found no method or library to change how a function inside parser's object will behave. Can you guys help?