Merge pull request #267 from spalger/fix/promiseRejection

[transport/request] ensure the return value gets defined
This commit is contained in:
Spencer
2015-09-10 15:25:54 -07:00
3 changed files with 36 additions and 21 deletions

View File

@ -360,7 +360,8 @@ describe('Transport Class', function () {
done();
});
});
it('rejects get requests with bodies', function (done) {
it('rejects GET requests with a body (callback)', function (done) {
var trans = new Transport();
stub(trans.log, 'debug');
stub(trans.connectionPool, 'select', function (cb) {
@ -377,6 +378,26 @@ describe('Transport Class', function () {
});
});
it('rejects GET requests with a body (promise)', function (done) {
var trans = new Transport();
stub(trans.log, 'debug');
stub(trans.connectionPool, 'select', function (cb) {
// simulate "no connections"
process.nextTick(cb);
});
trans.request({
body: 'JSON!!',
method: 'GET'
})
.then(function () {
done(new Error('expected the request to fail!'));
}, function (err) {
expect(err).to.be.a(TypeError);
expect(err.message).to.match(/body.*method.*get/i);
done();
});
});
describe('gets a body', function () {
it('serializes it', function (done) {
var trans = new Transport({