title: How do I properly test promises with mocha and chai?
body: <p>The following test is behaving oddly:</p>
  
  <pre><code>it('Should return the exchange rates for btc_ltc', function(done) {
      var pair = 'btc_ltc';
  
      shapeshift.getRate(pair)
          .then(function(data){
              expect(data.pair).to.equal(pair);
              expect(data.rate).to.have.length(400);
              done();
          })
          .catch(function(err){
              //this should really be `.catch` for a failed request, but
              //instead it looks like chai is picking this up when a test fails
              done(err);
          })
  });
  </code></pre>
  
  <p>How should I properly handle a rejected promise (and test it)?</p>
  
  <p>How should I properly handle a failed test (ie: <code>expect(data.rate).to.have.length(400);</code>?</p>
  
  <p>Here is the implementation I'm testing:</p>
  
  <pre><code>var requestp = require('request-promise');
  var shapeshift = module.exports = {};
  var url = 'http://shapeshift.io';
  
  shapeshift.getRate = function(pair){
      return requestp({
          url: url + '/rate/' + pair,
          json: true
      });
  };
  </code></pre>