fix mocha and add header tests
This commit is contained in:
parent
4b67a2d265
commit
9c8090b06d
1 changed files with 21 additions and 3 deletions
|
|
@ -12,6 +12,7 @@ describe('insight storage plugin', function() {
|
||||||
var password = '1234';
|
var password = '1234';
|
||||||
|
|
||||||
var data = '{"random": true}';
|
var data = '{"random": true}';
|
||||||
|
var headers = 'X-test: 12\r\nX-testb: 32';
|
||||||
var namespace = 'profile::0000000000000000000000000000000000000000';
|
var namespace = 'profile::0000000000000000000000000000000000000000';
|
||||||
|
|
||||||
var oldSecret = 'rFA+F/N+ZvKXp717zBdfCKYQ5v9Fjry0W6tautj5etIH' + 'KLQliZBEYXA7AXjTJ9K3DglzGWJKost3QJUCMbhM/A=='
|
var oldSecret = 'rFA+F/N+ZvKXp717zBdfCKYQ5v9Fjry0W6tautj5etIH' + 'KLQliZBEYXA7AXjTJ9K3DglzGWJKost3QJUCMbhM/A=='
|
||||||
|
|
@ -47,7 +48,8 @@ describe('insight storage plugin', function() {
|
||||||
|
|
||||||
var setupForRetrieval = function() {
|
var setupForRetrieval = function() {
|
||||||
requestMock.get.onFirstCall().callsArgWith(1, null, {
|
requestMock.get.onFirstCall().callsArgWith(1, null, {
|
||||||
statusCode: 200
|
statusCode: 200,
|
||||||
|
getAllResponseHeaders: sinon.stub().returns(headers),
|
||||||
}, data);
|
}, 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() {
|
var setupForSave = function() {
|
||||||
requestMock.post.onFirstCall().callsArgWith(1, null, {
|
requestMock.post.onFirstCall().callsArgWith(1, null, {
|
||||||
statusCode: 200
|
statusCode: 200
|
||||||
|
|
@ -106,11 +122,13 @@ describe('insight storage plugin', function() {
|
||||||
statusCode: 403
|
statusCode: 403
|
||||||
});
|
});
|
||||||
requestMock.get.onSecondCall().callsArgWith(1, null, {
|
requestMock.get.onSecondCall().callsArgWith(1, null, {
|
||||||
statusCode: 200
|
statusCode: 200,
|
||||||
|
getAllResponseHeaders: sinon.stub(),
|
||||||
}, data);
|
}, data);
|
||||||
requestMock.post = sinon.stub();
|
requestMock.post = sinon.stub();
|
||||||
requestMock.post.onFirstCall().callsArgWith(1, null, {
|
requestMock.post.onFirstCall().callsArgWith(1, null, {
|
||||||
statusCode: 200
|
statusCode: 200,
|
||||||
|
getAllResponseHeaders: sinon.stub(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue