Tuesday, 25 April 2017

getById() returns undefined Promise

I have the following class method in my Sequelize model:

getById(id) {
      return new Promise((resolve, reject) => {
          var Conference = sequelize.models.conference;
          Conference.findById(id).then(function(conference) {
              if (_.isObject(conference)) {
                  resolve(conference);
              } else {
                  throw new ResourceNotFound(conference.name, {id: id});
              }
          }).catch(function(err) {
              reject(err);
          });
      });
  }

Now I want to test my method with chai. But now when I do Conference.getById(confereceId) I get the following back:

Promise {
  _bitField: 0,
  _fulfillmentHandler0: undefined,
  _rejectionHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined }

Is this right and how do I test it with chai?



via mrks

No comments:

Post a Comment