I'm using agenda framework for job scheduling link https://github.com/agenda/agenda
Scheduling a job it sends email to user, it's working fine, but I want to write unit test for current code. Any help appreciated
this jobs runs as process for example node jobname
module.exports = function (agenda) {
agenda.define('sendemail', function (task, done) {
// Sending email logic here
})
// Success event when job run successfully,
agenda.on('success:sendemail', function (task) {
// send email to admin job run successfully
})
// Fail event when job failed
agenda.on('fail:sendemail', function (err, task) {
// send email to admin job failed
})
// Run sendemail job
agenda.on('ready', function () {
agenda.schedule('in 5 seconds', 'sendemail', {
time: new Date()
})
agenda.start()
})
}
sendemail has different state success,failure For sending email using AWS SES service. Want to write unit test for above code and want to verify whether job succeed or failed.