From d3c8e0e175887278274a20cbfcac38b36e7adeea Mon Sep 17 00:00:00 2001 From: Ewan Dennis Date: Mon, 22 Feb 2016 18:09:39 +0000 Subject: [PATCH] zlib.gzipSync() -> zlib.gzip(...) --- test/spec/sparkpost.spec.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/test/spec/sparkpost.spec.js b/test/spec/sparkpost.spec.js index 1fcc596..56ba899 100644 --- a/test/spec/sparkpost.spec.js +++ b/test/spec/sparkpost.spec.js @@ -169,8 +169,17 @@ describe('SparkPost Library', function() { it('should accept gzipped responses', function(done) { var TEST_MESSAGE = 'This is a compressible test and it is full of compressible test stuff.' - , compressedMsg = zlib.gzipSync(TEST_MESSAGE + TEST_MESSAGE) - , gzipNock = nock('https://test.sparkpost.com', { + , compressedMsg + , gzipNock + , options = { + method: 'GET' + , uri: 'https://test.sparkpost.com/test' + }; + + zlib.gzip(TEST_MESSAGE+TEST_MESSAGE, function(err, gzipped) { + expect(err).to.be.null; + compressedMsg = gzipped; + gzipNock = nock('https://test.sparkpost.com', { reqheaders: { 'accept-encoding': 'gzip' } @@ -180,19 +189,15 @@ describe('SparkPost Library', function() { 'X-Transfer-Length': String(compressedMsg.length) , 'Content-Length': undefined , 'Content-Encoding': 'gzip' - }) - , options = { - method: 'GET' - , uri: 'https://test.sparkpost.com/test' - }; - - client.request(options, function(err, data) { - expect(err).to.be.null; - expect(data.statusCode).to.equal(200); - expect(data.body).to.equal(TEST_MESSAGE + TEST_MESSAGE); + }); + client.request(options, function(err, data) { + expect(err).to.be.null; + expect(data.statusCode).to.equal(200); + expect(data.body).to.equal(TEST_MESSAGE + TEST_MESSAGE); - // finish async test - done(); + // finish async test + done(); + }); }); });