From 9c8090b06d6c5d2176729ae422c8f11becab4bbd Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Tue, 2 Dec 2014 03:07:35 -0300 Subject: [PATCH] fix mocha and add header tests --- test/plugin.insight.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/test/plugin.insight.js b/test/plugin.insight.js index c086d6ea1..1f94ff8bf 100644 --- a/test/plugin.insight.js +++ b/test/plugin.insight.js @@ -12,6 +12,7 @@ describe('insight storage plugin', function() { var password = '1234'; var data = '{"random": true}'; + var headers = 'X-test: 12\r\nX-testb: 32'; var namespace = 'profile::0000000000000000000000000000000000000000'; var oldSecret = 'rFA+F/N+ZvKXp717zBdfCKYQ5v9Fjry0W6tautj5etIH' + 'KLQliZBEYXA7AXjTJ9K3DglzGWJKost3QJUCMbhM/A==' @@ -47,7 +48,8 @@ describe('insight storage plugin', function() { var setupForRetrieval = function() { requestMock.get.onFirstCall().callsArgWith(1, null, { - statusCode: 200 + statusCode: 200, + getAllResponseHeaders: sinon.stub().returns(headers), }, data); }; @@ -62,6 +64,20 @@ describe('insight storage plugin', function() { }); }); + it('should be able to retrieve headers', function(done) { + + setupForRetrieval(); + + storage.getItem(namespace, function(err, retrieved, headers) { + assert(!err); + headers['X-test'].should.equal('12'); + headers['X-testb'].should.equal('32'); + return done(); + }); + }); + + + var setupForSave = function() { requestMock.post.onFirstCall().callsArgWith(1, null, { statusCode: 200 @@ -106,11 +122,13 @@ describe('insight storage plugin', function() { statusCode: 403 }); requestMock.get.onSecondCall().callsArgWith(1, null, { - statusCode: 200 + statusCode: 200, + getAllResponseHeaders: sinon.stub(), }, data); requestMock.post = sinon.stub(); requestMock.post.onFirstCall().callsArgWith(1, null, { - statusCode: 200 + statusCode: 200, + getAllResponseHeaders: sinon.stub(), }); }