[transport] before failing to send a request, ensure the return value is defined

This commit is contained in:
spalger
2015-09-08 21:06:57 -07:00
parent cd336c6d6e
commit a9175dad58
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({