@mendeley/api
Advanced tools
Comparing version 7.0.2 to 7.1.0
@@ -22,3 +22,2 @@ 'use strict'; | ||
/** | ||
@@ -41,2 +40,3 @@ * Pass the second argument as it is. This is to allow receiving non-standard | ||
function normaliseOptions(options) { | ||
options.requestFilter = options.requestFilter || passFilter; | ||
options.responseFilter = options.responseFilter || dataFilter; | ||
@@ -107,2 +107,4 @@ options.args = options.args || []; | ||
request = options.requestFilter(options, request); | ||
return Request.create(request, settings) | ||
@@ -148,2 +150,4 @@ .send() | ||
request = options.requestFilter(options, request); | ||
return Request.create(request, settings) | ||
@@ -194,2 +198,4 @@ .send() | ||
request = options.requestFilter(options, request); | ||
return Request.create(request, settings) | ||
@@ -196,0 +202,0 @@ .send() |
{ | ||
"name": "@mendeley/api", | ||
"version": "7.0.2", | ||
"version": "7.1.0", | ||
"description": "Mendeley API JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -168,2 +168,28 @@ 'use strict'; | ||
it('should allow the request to be modified using a requestFilter', function() { | ||
var requestFunction = utils.requestFun(assign({ | ||
requestFilter: function(options, request) { | ||
request.headers.foo = 'bar'; | ||
return request; | ||
}, | ||
method: 'GET', | ||
resource: '/test' | ||
}, defaultOptions)); | ||
requestFunction(); | ||
expect(requestCreateSpy).toHaveBeenCalledWith({ | ||
method: 'GET', | ||
responseType: 'json', | ||
url: 'https://api.mendeley.com/test', | ||
headers: { | ||
foo: 'bar' | ||
}, | ||
params: undefined | ||
}, { | ||
authFlow: authFlow, | ||
maxRetries: 1 | ||
}); | ||
}); | ||
}); | ||
@@ -238,2 +264,27 @@ | ||
it('should allow the request to be modified using a requestFilter', function() { | ||
var requestFunction = utils.requestWithDataFun(assign({ | ||
requestFilter: function(options, request) { | ||
request.headers.foo = 'bar'; | ||
return request; | ||
}, | ||
method: 'POST', | ||
resource: '/test' | ||
}, defaultOptions)); | ||
requestFunction(); | ||
expect(requestCreateSpy).toHaveBeenCalledWith({ | ||
method: 'POST', | ||
url: 'https://api.mendeley.com/test', | ||
headers: { | ||
foo: 'bar' | ||
}, | ||
data: undefined | ||
}, { | ||
authFlow: authFlow, | ||
followLocation: undefined | ||
}); | ||
}); | ||
}); | ||
@@ -332,2 +383,28 @@ | ||
it('should allow the request to be modified using a requestFilter', function() { | ||
var requestFunction = utils.requestWithFileFun(assign({ | ||
requestFilter: function(options, request) { | ||
request.headers.foo = 'bar'; | ||
return request; | ||
}, | ||
method: 'POST', | ||
resource: '/test' | ||
}, defaultOptions)); | ||
requestFunction(file, 'zelda'); | ||
expect(requestCreateSpy).toHaveBeenCalledWith({ | ||
method: 'POST', | ||
url: 'https://api.mendeley.com/test', | ||
headers: assign({ | ||
foo: 'bar' | ||
}, headers), | ||
data: file, | ||
onUploadProgress: undefined, | ||
onDownloadProgress: undefined | ||
}, { | ||
authFlow: authFlow | ||
}); | ||
}); | ||
}); | ||
@@ -334,0 +411,0 @@ |
1524113
15545