From c57adca39b1af9ed8bc9af4eca5867b03879e0a5 Mon Sep 17 00:00:00 2001
From: "Aydrian J. Howard" <aydrian@gmail.com>
Date: Fri, 1 Apr 2016 12:12:23 -0400
Subject: [PATCH] Added test for null response body

---
 test/spec/sparkpost.spec.js | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/test/spec/sparkpost.spec.js b/test/spec/sparkpost.spec.js
index 56ba899..3e10f59 100644
--- a/test/spec/sparkpost.spec.js
+++ b/test/spec/sparkpost.spec.js
@@ -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')
@@ -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();
         });