[transport] before failing to send a request, ensure the return value is defined
This commit is contained in:
@ -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({
|
||||
|
||||
Reference in New Issue
Block a user