Skip to content

Commit

Permalink
Added test for null response body
Browse files Browse the repository at this point in the history
  • Loading branch information
aydrian committed Apr 1, 2016
1 parent 02203d7 commit c57adca
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/spec/sparkpost.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@ describe('SparkPost Library', function() {
});
});

it('should return an error if statusCode not 2XX and there is no body', function(done) {
// simulate a timeout
nock('https://api.sparkpost.com')
.post('/api/v1/post/test/fail')
.reply(422);

var options = {
method: 'POST'
, uri: 'post/test/fail'
};

client.request(options, function(err, data) {
expect(data).to.be.defined;
expect(err).to.be.defined;

expect(err.errors).to.be.undefined;

// finish async test
done();
});
});

it('should use a full URI if provided', function(done) {
nock('https://test.sparkpost.com')
.get('/test')
Expand Down Expand Up @@ -194,7 +216,7 @@ describe('SparkPost Library', function() {
expect(err).to.be.null;
expect(data.statusCode).to.equal(200);
expect(data.body).to.equal(TEST_MESSAGE + TEST_MESSAGE);

// finish async test
done();
});
Expand Down

0 comments on commit c57adca

Please sign in to comment.