I need help with the help of your application, I'm trying to test a function that returns a promise.coroutine and I'm not getting it anyway ...
const addClientUpdateTodo = (cliente) => {
let responseClient, responseTodo
return new (Promise.coroutine(function* () {
try {
yield knex.transaction(function (trx) {
addClient(trx, cliente)
.then((resp) => {
responseClient = resp
return updateTodo(trx, cliente)
.then(() => {
responseTodo = 'Transaction Complete'
})
.catch(trx.rollback)
})
.then(trx.commit)
.catch(trx.rollback)
})
return { idCliente: responseClient[0], message: responseTodo }
} catch (err) {
return { message: 'Error', err }
}
}))
}
This method above is what I am trying to test ... I have tried to test in some ways with sinon.stub (), resolves or .returns and still can not test the part in which it enters the promise ... vcs could help me?