Promise test of co-routine in NodeJS with mocha and sinnon

0

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?

    
asked by anonymous 19.09.2018 / 20:04

0 answers