@mendeley/api
Advanced tools
Comparing version 7.2.0 to 8.0.0
@@ -14,3 +14,3 @@ /*jshint camelcase: false */ | ||
var sdk = require('../lib/api'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../lib/promise-proxy'); | ||
var accessTokenCookieName = 'accessToken'; | ||
@@ -119,5 +119,5 @@ var refreshTokenCookieName = 'refreshToken'; | ||
if (!refreshToken) { | ||
return Bluebird.reject(new Error('No refresh token')); | ||
return Promise.reject(new Error('No refresh token')); | ||
} else { | ||
return new Bluebird(function(resolve, reject) { | ||
return new Promise(function(resolve, reject) { | ||
oauth2.accessToken.create({ | ||
@@ -158,3 +158,3 @@ access_token: accessToken, | ||
console.log('Refreshing token'); | ||
return new Bluebird(function(resolve, reject) { | ||
return new Promise(function(resolve, reject) { | ||
oauth2.client.getToken({ | ||
@@ -161,0 +161,0 @@ scope: 'all' |
// Karma configuration | ||
// Generated on Fri Sep 12 2014 15:16:30 GMT+0100 (BST) | ||
var webpack = require('webpack'); | ||
module.exports = function(config) { | ||
@@ -70,3 +72,6 @@ | ||
webpack: require(process.cwd() + '/webpack.config'), | ||
webpack: Object.assign( {}, | ||
require(process.cwd() + '/webpack.config'), | ||
{ plugins: [new webpack.ProvidePlugin({ Promise: 'es6-promise-promise' })] } | ||
), | ||
@@ -73,0 +78,0 @@ // Prevents webpack from logging stats on all the chunks |
'use strict'; | ||
var assign = require('object-assign'); | ||
var Bluebird = require('bluebird'); | ||
var utils = require('./utilities'); | ||
Bluebird.config({ | ||
warnings: false, | ||
wForgottenReturn: false | ||
}); | ||
try { | ||
@@ -13,0 +7,0 @@ // prevent crashing in node-like environments |
@@ -7,2 +7,3 @@ 'use strict'; | ||
var mimeTypes = require('./mime-types'); | ||
var PromiseProxy = require('./promise-proxy'); | ||
@@ -40,1 +41,15 @@ // Exports Mendeley SDK | ||
module.exports.MimeTypes = mimeTypes; | ||
/** | ||
* Allows a custom Promise library to be used. | ||
* The method is chainable to allow ease of use when importing, for example: | ||
* | ||
* var api = require('@mendeley/api').withPromise(require('bluebird')); | ||
* | ||
* @param {Promise} customPromise | ||
* @returns {function} | ||
*/ | ||
module.exports.withPromise = function(customPromise) { | ||
PromiseProxy.setPromise(customPromise); | ||
return module.exports; | ||
}; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var assign = require('object-assign'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('./promise-proxy'); | ||
@@ -163,3 +163,3 @@ var defaults = { | ||
this.settings.authFlow.authenticate(); | ||
return Bluebird.reject(new Error('No token')); | ||
return Promise.reject(new Error('No token')); | ||
} | ||
@@ -166,0 +166,0 @@ } |
@@ -5,3 +5,2 @@ 'use strict'; | ||
var assign = require('object-assign'); | ||
var Bluebird = require('bluebird'); | ||
var pagination = require('./pagination'); | ||
@@ -8,0 +7,0 @@ |
{ | ||
"name": "@mendeley/api", | ||
"version": "7.2.0", | ||
"version": "8.0.0", | ||
"description": "Mendeley API JavaScript SDK", | ||
@@ -34,2 +34,3 @@ "directories": { | ||
"es5-shim": "^4.5.9", | ||
"es6-promise-promise": "^1.0.0", | ||
"express": "^4.9.5", | ||
@@ -58,3 +59,2 @@ "jasmine": "^2.4.1", | ||
"axios": "^0.14.0", | ||
"bluebird": "^3.4.0", | ||
"form-urlencoded": "^1.4.1", | ||
@@ -61,0 +61,0 @@ "object-assign": "^4.1.0" |
@@ -36,3 +36,3 @@ # Mendeley JavaScript SDK | ||
plugins: [new webpack.ProvidePlugin({ | ||
Promise: 'bluebird' | ||
Promise: 'es6-promise-promise' | ||
})]; | ||
@@ -42,2 +42,8 @@ } | ||
Alternatively, you can pass your own Promise implementation at runtime: | ||
```js | ||
var sdk = require('@mendeley/api').withPromise(require('bluebird')); | ||
``` | ||
Some ECMAScript5 features are used so for older browsers you may need to shim these methods, for example with [es5-shim][]. | ||
@@ -200,3 +206,3 @@ | ||
Methods that make API calls return [Bluebird promises][]. Each call will either resolve with some data or reject with a response object according to the response from [axios][]. Here's an example using the standalone version: | ||
Methods that make API calls return [ES6 Promises][]. Each call will either resolve with some data or reject with a response object according to the response from [axios][]. Here's an example using the standalone version: | ||
@@ -371,3 +377,3 @@ ```javascript | ||
[Bluebird promises]:http://bluebirdjs.com/docs/api-reference.html | ||
[ES6 Promises]:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise | ||
[axios]:https://github.com/mzabriskie/axios#response-schema | ||
@@ -374,0 +380,0 @@ [es5-shim]:https://github.com/es-shims/es5-shim |
'use strict'; | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../lib/promise-proxy'); | ||
@@ -45,3 +45,3 @@ var unauthorisedError = new Error(); | ||
fakeToken = 'auth-refreshed'; | ||
return Bluebird.resolve(); | ||
return Promise.resolve(); | ||
} | ||
@@ -59,3 +59,3 @@ }; | ||
refreshToken: function() { | ||
return new Bluebird(function (resolve) { | ||
return new Promise(function (resolve) { | ||
setTimeout(function () { | ||
@@ -62,0 +62,0 @@ refreshCount++; |
@@ -5,3 +5,3 @@ /* jshint camelcase: false */ | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -27,9 +27,11 @@ var baseUrl = 'https://api.mendeley.com'; | ||
expect(typeof annotationsApi.list).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
annotationsApi.list(params).finally(function() { | ||
annotationsApi.list(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -66,8 +68,10 @@ | ||
expect(typeof annotationsApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
annotationsApi.retrieve(123).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
annotationsApi.retrieve(123).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -103,8 +107,10 @@ | ||
expect(typeof annotationsApi.create).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
annotationsApi.create(requestData).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
annotationsApi.create(requestData).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -140,8 +146,10 @@ | ||
expect(typeof annotationsApi.delete).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
annotationsApi.delete(123).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
annotationsApi.delete(123).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -174,8 +182,10 @@ | ||
expect(typeof annotationsApi.patch).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
annotationsApi.patch(123, requestData).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
annotationsApi.patch(123, requestData).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -212,3 +222,3 @@ | ||
function ajaxSpy() { | ||
return spyOn(axios, 'request').and.returnValue(Bluebird.resolve({ | ||
return spyOn(axios, 'request').and.returnValue(Promise.resolve({ | ||
headers: { | ||
@@ -239,6 +249,8 @@ link: '<' + linkNext + '>; rel="next",<' + linkLast + '>; rel="last",<' + linkFirst + '>; rel="first"', | ||
}) | ||
.finally(function() { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkNext); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -252,6 +264,8 @@ | ||
}) | ||
.finally(function() { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkLast); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -258,0 +272,0 @@ |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var sdk = require('../../../'); | ||
@@ -24,8 +23,10 @@ var baseUrl = 'https://api.mendeley.com'; | ||
expect(typeof catalogApi.search).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
catalogApi.search(params).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
catalogApi.search(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -65,8 +66,10 @@ | ||
expect(typeof catalogApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
catalogApi.retrieve('catalogId', params).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
catalogApi.retrieve('catalogId', params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -73,0 +76,0 @@ |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var sdk = require('../../../'); | ||
@@ -23,3 +22,3 @@ var baseUrl = 'https://api.mendeley.com'; | ||
// Mock ajax response promises | ||
var mockPromiseCreate = Bluebird.resolve({ | ||
var mockPromiseCreate = Promise.resolve({ | ||
data: '', | ||
@@ -32,3 +31,3 @@ status: 201, | ||
var mockPromiseRetrieve = Bluebird.resolve({ | ||
var mockPromiseRetrieve = Promise.resolve({ | ||
data: { id: '15', title: 'foo' }, | ||
@@ -39,3 +38,3 @@ status: 200, | ||
var mockPromiseCreateFromFile = Bluebird.resolve({ | ||
var mockPromiseCreateFromFile = Promise.resolve({ | ||
data: { id: '15', title: 'foo' }, | ||
@@ -48,3 +47,3 @@ status: 201, | ||
var mockPromiseUpdate = Bluebird.resolve({ | ||
var mockPromiseUpdate = Promise.resolve({ | ||
data: { id: '15', title: 'foo' }, | ||
@@ -57,3 +56,3 @@ status: 200, | ||
var mockPromiseClone = Bluebird.resolve({ | ||
var mockPromiseClone = Promise.resolve({ | ||
data: { id: '16', title: 'foo', 'group_id': 'bar' }, | ||
@@ -66,3 +65,3 @@ status: 200, | ||
var mockPromiseList = Bluebird.resolve({ | ||
var mockPromiseList = Promise.resolve({ | ||
data: [{ id: '15', title: 'foo' }], | ||
@@ -75,3 +74,3 @@ status: 200, | ||
var mockPromiseTrash = Bluebird.resolve({ | ||
var mockPromiseTrash = Promise.resolve({ | ||
data: null, | ||
@@ -84,5 +83,5 @@ status: 204, | ||
var mockPromiseNotFound = Bluebird.reject({ response: { status: 404 } }); | ||
var mockPromiseNotFound = Promise.reject({ response: { status: 404 } }); | ||
var mockPromiseInternalError = Bluebird.reject({ response: { status: 500 } }); | ||
var mockPromiseInternalError = Promise.reject({ response: { status: 500 } }); | ||
@@ -109,34 +108,44 @@ // Get a function to return promises in order | ||
expect(typeof documentsApi.create).toBe('function'); | ||
documentsApi.create({ title: 'foo' }).finally(function() { | ||
documentsApi.create({ title: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should use POST', function(done) { | ||
documentsApi.create({ title: 'foo' }).finally(function() { | ||
documentsApi.create({ title: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.method).toBe('post'); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should use endpoint /documents', function(done) { | ||
documentsApi.create({ title: 'foo' }).finally(function() { | ||
documentsApi.create({ title: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.url).toBe(baseUrl + '/documents'); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should have a Content-Type header', function(done) { | ||
documentsApi.create({ title: 'foo' }).finally(function() { | ||
documentsApi.create({ title: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.headers['Content-Type']).toBeDefined(); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should have an Authorization header', function(done) { | ||
documentsApi.create({ title: 'foo' }).finally(function() { | ||
documentsApi.create({ title: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
@@ -146,3 +155,3 @@ expect(ajaxRequest.headers.Authorization).toBeDefined(); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -152,11 +161,15 @@ | ||
var requestData = { title: 'foo' }; | ||
documentsApi.create(requestData).finally(function() { | ||
documentsApi.create(requestData).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.data).toBe(requestData); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should follow Location header', function(done) { | ||
documentsApi.create({ title: 'foo' }).finally(function() { | ||
documentsApi.create({ title: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
@@ -167,3 +180,3 @@ var ajaxRedirect = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -210,26 +223,34 @@ | ||
expect(typeof documentsApi.createFromFile).toBe('function'); | ||
documentsApi.createFromFile(file).finally(function() { | ||
documentsApi.createFromFile(file).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should use POST', function(done) { | ||
documentsApi.createFromFile(file).finally(function() { | ||
documentsApi.createFromFile(file).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.method).toBe('post'); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should use endpoint /documents', function(done) { | ||
documentsApi.createFromFile(file).finally(function() { | ||
documentsApi.createFromFile(file).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.url).toBe(baseUrl + '/documents'); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should have a Content-Type header the same as the file', function(done) { | ||
documentsApi.createFromFile(file).finally(function() { | ||
documentsApi.createFromFile(file).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
@@ -239,15 +260,19 @@ expect(ajaxRequest.headers['Content-Type']).toBeDefined(); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should have a Content-Disposition header based on file name', function(done) { | ||
documentsApi.createFromFile(file).finally(function() { | ||
documentsApi.createFromFile(file).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.headers['Content-Disposition']).toEqual('attachment; filename*=UTF-8\'\'%E4%B8%AD%E6%96%87file%20name%281%29.pdf'); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should have an Authorization header', function(done) { | ||
documentsApi.createFromFile(file).finally(function() { | ||
documentsApi.createFromFile(file).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
@@ -257,11 +282,13 @@ expect(ajaxRequest.headers.Authorization).toBeDefined(); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should have a body of the file contents', function(done) { | ||
documentsApi.createFromFile(file).finally(function() { | ||
documentsApi.createFromFile(file).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.data).toEqual(file); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -287,7 +314,9 @@ | ||
ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(mockPromiseCreateFromFile)); | ||
apiRequest = documentsApi.createFromFileInGroup(file, 123).finally(function() { | ||
apiRequest = documentsApi.createFromFileInGroup(file, 123).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -307,7 +336,9 @@ | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(mockPromiseRetrieve)); | ||
documentsApi.retrieve(15).finally(function() { | ||
documentsApi.retrieve(15).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -358,7 +389,9 @@ | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(mockPromiseUpdate)); | ||
documentsApi.update(15, requestData).finally(function() { | ||
documentsApi.update(15, requestData).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -397,7 +430,10 @@ | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(mockPromiseClone)); | ||
apiRequest = documentsApi.clone(15, requestData).finally(function() { | ||
apiRequest = documentsApi.clone(15, requestData).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
return arguments[0]; | ||
} | ||
}); | ||
@@ -447,7 +483,9 @@ | ||
documentsApi.list(params).finally(function() { | ||
documentsApi.list(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -490,7 +528,9 @@ | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(mockPromiseList)); | ||
documentsApi.list(params).finally(function() { | ||
documentsApi.list(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -519,7 +559,9 @@ | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(mockPromiseTrash)); | ||
documentsApi.trash(15).finally(function() { | ||
documentsApi.trash(15).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -551,3 +593,3 @@ | ||
it('should retry on 504', function(done) { | ||
ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(Bluebird.reject({ response: { status: 504 } }), mockPromiseList)); | ||
ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(Promise.reject({ response: { status: 504 } }), mockPromiseList)); | ||
documentsApi.list().then(function() { | ||
@@ -561,3 +603,3 @@ expect(ajaxSpy).toHaveBeenCalled(); | ||
it('should only retry once', function(done) { | ||
ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(Bluebird.reject({ response: { status: 504 } }), Bluebird.reject({ response: { status: 504 } }), mockPromiseList)); | ||
ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(Promise.reject({ response: { status: 504 } }), Promise.reject({ response: { status: 504 } }), mockPromiseList)); | ||
documentsApi.list().catch(function() { | ||
@@ -610,3 +652,3 @@ expect(ajaxSpy).toHaveBeenCalled(); | ||
spy.and.returnValue(Bluebird.resolve({ | ||
spy.and.returnValue(Promise.resolve({ | ||
headers: headers | ||
@@ -638,6 +680,8 @@ })); | ||
}) | ||
.finally(function () { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkNext); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -652,6 +696,8 @@ | ||
}) | ||
.finally(function () { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkPrev); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -666,6 +712,8 @@ | ||
}) | ||
.finally(function () { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkLast); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -672,0 +720,0 @@ |
@@ -5,3 +5,3 @@ /* jshint sub: true */ | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -34,3 +34,3 @@ var baseUrl = 'https://api.mendeley.com'; | ||
}; | ||
return Bluebird.resolve({ | ||
return Promise.resolve({ | ||
data: fileResource, | ||
@@ -47,7 +47,9 @@ status: 201, | ||
ajaxSpy = spyOn(axios, 'request').and.callFake(ajaxResponse); | ||
filesApi.create(file, 123).finally(function() { | ||
filesApi.create(file, 123).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
done(); | ||
}); | ||
} | ||
@@ -92,7 +94,9 @@ }); | ||
filesApi.create(123, typelessFile).finally(function() { | ||
filesApi.create(123, typelessFile).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.headers['Content-Type']).toEqual('application/octet-stream'); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -112,9 +116,12 @@ }); | ||
expect(typeof filesApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve(sampleResponse)); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve(sampleResponse)); | ||
responsePromise = filesApi.retrieve('someId').finally(function() { | ||
responsePromise = filesApi.retrieve('someId').then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
return arguments[0]; | ||
} | ||
}); | ||
@@ -152,3 +159,3 @@ | ||
expect(typeof filesApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
filesApi.retrieve('someId'); | ||
@@ -163,3 +170,3 @@ | ||
expect(typeof filesApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
filesApi.retrieve('someId'); | ||
@@ -181,8 +188,10 @@ | ||
expect(typeof filesApi.list).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
filesApi.list('someId').finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
filesApi.list('someId').then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -224,8 +233,11 @@ | ||
expect(typeof filesApi.remove).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
filesApi.remove('fileId').finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
filesApi.remove('fileId').then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
return arguments[0]; | ||
} | ||
}); | ||
@@ -232,0 +244,0 @@ |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -23,3 +23,3 @@ var baseUrl = 'https://api.mendeley.com'; | ||
if (ajaxCalls++ % 2 === 0) { | ||
return Bluebird.resolve({ | ||
return Promise.resolve({ | ||
status: 201, | ||
@@ -31,3 +31,3 @@ headers: { | ||
} else { | ||
return Bluebird.resolve({ | ||
return Promise.resolve({ | ||
status: 200, | ||
@@ -46,36 +46,44 @@ data: { id: '123', name: 'foo' }, | ||
expect(typeof foldersApi.create).toBe('function'); | ||
foldersApi.create({ name: 'foo' }).finally(function() { | ||
foldersApi.create({ name: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should use POST', function(done) { | ||
foldersApi.create({ name: 'foo' }).finally(function() { | ||
foldersApi.create({ name: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.method).toBe('post'); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should use endpoint /folders', function(done) { | ||
foldersApi.create({ name: 'foo' }).finally(function() { | ||
foldersApi.create({ name: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.url).toBe(baseUrl + '/folders'); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should have a Content-Type header', function(done) { | ||
foldersApi.create({ name: 'foo' }).finally(function() { | ||
foldersApi.create({ name: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.headers['Content-Type']).toBeDefined(); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should have an Authorization header', function(done) { | ||
foldersApi.create({ name: 'foo' }).finally(function() { | ||
foldersApi.create({ name: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
@@ -85,4 +93,3 @@ expect(ajaxRequest.headers.Authorization).toBeDefined(); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -92,11 +99,15 @@ | ||
var requestData = { name: 'foo' }; | ||
foldersApi.create(requestData).finally(function() { | ||
foldersApi.create(requestData).then(_finally, _finally); | ||
function _finally() { | ||
ajaxRequest = ajaxSpy.calls.first().args[0]; | ||
expect(ajaxRequest.data).toBe(requestData); | ||
done(); | ||
}); | ||
} | ||
}); | ||
it('should follow Location header', function(done) { | ||
foldersApi.create({ name: 'foo' }).finally(function() { | ||
foldersApi.create({ name: 'foo' }).then(_finally, _finally); | ||
function _finally() { | ||
var ajaxRedirect = ajaxSpy.calls.mostRecent().args[0]; | ||
@@ -106,3 +117,3 @@ expect(ajaxRedirect.method).toBe('get'); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -122,3 +133,3 @@ | ||
var ajaxFailureResponse = function() { | ||
return Bluebird.reject({ response: { status: 500 } }); | ||
return Promise.reject({ response: { status: 500 } }); | ||
}; | ||
@@ -137,3 +148,3 @@ spyOn(axios, 'request').and.callFake(ajaxFailureResponse); | ||
if (ajaxMixedCalls++ === 0) { | ||
return Bluebird.resolve({ | ||
return Promise.resolve({ | ||
headers: { | ||
@@ -147,3 +158,3 @@ location: baseUrl + '/folders/123' | ||
else { | ||
return Bluebird.reject({ response: { status: 404 } }); | ||
return Promise.reject({ response: { status: 404 } }); | ||
} | ||
@@ -166,3 +177,3 @@ }; | ||
expect(typeof foldersApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
foldersApi.retrieve(123); | ||
@@ -202,3 +213,3 @@ expect(ajaxSpy).toHaveBeenCalled(); | ||
var ajaxResponse = function() { | ||
return Bluebird.resolve({ | ||
return Promise.resolve({ | ||
data: { id: '123', name: 'bar' }, | ||
@@ -250,3 +261,3 @@ headers: {} | ||
expect(typeof foldersApi.list).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
@@ -301,3 +312,3 @@ foldersApi.list(params); | ||
spy.and.returnValue(Bluebird.resolve({ | ||
spy.and.returnValue(Promise.resolve({ | ||
data: [], | ||
@@ -331,6 +342,8 @@ headers: headers | ||
}) | ||
.finally(function () { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkNext); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -345,6 +358,8 @@ | ||
}) | ||
.finally(function () { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkLast); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -351,0 +366,0 @@ |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -24,8 +24,10 @@ var baseUrl = 'https://api.mendeley.com'; | ||
expect(typeof followersApi.create).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
followersApi.create(params).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
followersApi.create(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -65,9 +67,11 @@ | ||
expect(typeof followersApi.list).toBe('function'); | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
followersApi.list(params).finally(function() { | ||
followersApi.list(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -104,9 +108,11 @@ | ||
expect(typeof followersApi.remove).toBe('function'); | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
followersApi.remove(relationshipId).finally(function() { | ||
followersApi.remove(relationshipId).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -139,9 +145,11 @@ | ||
expect(typeof followersApi.accept).toBe('function'); | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
followersApi.accept(relationshipId, { status: 'following' }).finally(function() { | ||
followersApi.accept(relationshipId, { status: 'following' }).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -148,0 +156,0 @@ |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -24,9 +24,11 @@ var baseUrl = 'https://api.mendeley.com'; | ||
expect(typeof groupApi.list).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
groupApi.list(params).finally(function() { | ||
groupApi.list(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -62,8 +64,10 @@ | ||
expect(typeof groupApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
groupApi.retrieve(123).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
groupApi.retrieve(123).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -98,3 +102,3 @@ | ||
function ajaxSpy() { | ||
return spyOn(axios, 'request').and.returnValue(Bluebird.resolve({ | ||
return spyOn(axios, 'request').and.returnValue(Promise.resolve({ | ||
data: [], | ||
@@ -126,6 +130,8 @@ headers: { | ||
}) | ||
.finally(function() { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkNext); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -139,6 +145,8 @@ | ||
}) | ||
.finally(function() { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkLast); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -145,0 +153,0 @@ |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -24,8 +24,10 @@ var baseUrl = 'https://api.mendeley.com'; | ||
beforeEach(function(done) { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
institutionTreesApi.list(params).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
institutionTreesApi.list(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -65,8 +67,10 @@ | ||
beforeEach(function(done) { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
institutionTreesApi.retrieve('123').finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
institutionTreesApi.retrieve('123').then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -73,0 +77,0 @@ |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -25,8 +25,10 @@ var baseUrl = 'https://api.mendeley.com'; | ||
expect(typeof institutionsApi.search).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
institutionsApi.search(params).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
institutionsApi.search(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -63,8 +65,10 @@ | ||
expect(typeof institutionsApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
institutionsApi.retrieve('some-id').finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
institutionsApi.retrieve('some-id').then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -71,0 +75,0 @@ |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -25,8 +25,10 @@ var baseUrl = 'https://api.mendeley.com'; | ||
expect(typeof locationsApi.search).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
locationsApi.search(params).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
locationsApi.search(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -63,8 +65,10 @@ | ||
expect(typeof locationsApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
locationsApi.retrieve('some-id').finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
locationsApi.retrieve('some-id').then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -71,0 +75,0 @@ |
@@ -5,3 +5,3 @@ /* jshint sub: true */ | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -26,8 +26,10 @@ var baseUrl = 'https://api.mendeley.com'; | ||
expect(typeof metadataApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
metadataApi.retrieve(params).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
metadataApi.retrieve(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -34,0 +36,0 @@ |
@@ -5,3 +5,3 @@ /* jshint camelcase: false */ | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -17,3 +17,3 @@ var baseUrl = 'https://api.mendeley.com'; | ||
var mockPromiseUpdate = Bluebird.resolve({ | ||
var mockPromiseUpdate = Promise.resolve({ | ||
data: [], | ||
@@ -41,8 +41,10 @@ status: 200, | ||
expect(typeof profilesApi.me).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
profilesApi.me().finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
profilesApi.me().then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -79,8 +81,10 @@ | ||
expect(typeof profilesApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
profilesApi.retrieve(123).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
profilesApi.retrieve(123).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -117,7 +121,9 @@ | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(getMockPromises(mockPromiseUpdate)); | ||
profilesApi.update(requestData).finally(function() { | ||
profilesApi.update(requestData).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -152,8 +158,10 @@ | ||
beforeEach(function(done) { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
profilesApi.retrieveByEmail('test@test.com').finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
profilesApi.retrieveByEmail('test@test.com').then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -190,3 +198,3 @@ | ||
beforeEach(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
}); | ||
@@ -199,3 +207,5 @@ | ||
profilesApi.retrieveByIdentifier(params).finally(function() { | ||
profilesApi.retrieveByIdentifier(params).then(_finally, _finally); | ||
function _finally() { | ||
var ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
@@ -206,3 +216,3 @@ | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -215,3 +225,5 @@ | ||
profilesApi.retrieveByIdentifier(params).finally(function() { | ||
profilesApi.retrieveByIdentifier(params).then(_finally, _finally); | ||
function _finally() { | ||
var ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
@@ -222,3 +234,3 @@ | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -225,0 +237,0 @@ }); |
@@ -5,3 +5,3 @@ /* jshint camelcase: false */ | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -27,9 +27,11 @@ var baseUrl = 'https://api.mendeley.com'; | ||
expect(typeof subjectAreasApi.list).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
subjectAreasApi.list(params).finally(function() { | ||
subjectAreasApi.list(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -36,0 +38,0 @@ |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -21,8 +21,10 @@ var baseUrl = 'https://api.mendeley.com'; | ||
expect(typeof trashApi.retrieve).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
trashApi.retrieve(15).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
trashApi.retrieve(15).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -64,9 +66,11 @@ | ||
expect(typeof trashApi.list).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
trashApi.list(sampleData).finally(function() { | ||
trashApi.list(sampleData).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -102,8 +106,10 @@ | ||
expect(typeof trashApi.restore).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
trashApi.restore(15).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
trashApi.restore(15).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -136,3 +142,3 @@ | ||
var ajaxFailureResponse = function() { | ||
return Bluebird.reject({ response: { status: 404 } }); | ||
return Promise.reject({ response: { status: 404 } }); | ||
}; | ||
@@ -153,8 +159,10 @@ spyOn(axios, 'request').and.callFake(ajaxFailureResponse); | ||
expect(typeof trashApi.destroy).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
trashApi.destroy(15).finally(function() { | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
trashApi.destroy(15).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -206,3 +214,3 @@ | ||
spy.and.returnValue(Bluebird.resolve({ | ||
spy.and.returnValue(Promise.resolve({ | ||
headers: headers | ||
@@ -233,6 +241,8 @@ })); | ||
}) | ||
.finally(function() { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkNext); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -246,6 +256,8 @@ | ||
}) | ||
.finally(function() { | ||
.then(_finally, _finally); | ||
function _finally() { | ||
expect(spy.calls.mostRecent().args[0].url).toEqual(linkLast); | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -252,0 +264,0 @@ |
@@ -5,3 +5,3 @@ /* jshint camelcase: false */ | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var sdk = require('../../../'); | ||
@@ -27,9 +27,11 @@ var baseUrl = 'https://api.mendeley.com'; | ||
expect(typeof userRolesApi.list).toBe('function'); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.resolve({headers: {}})); | ||
ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.resolve({headers: {}})); | ||
userRolesApi.list(params).finally(function() { | ||
userRolesApi.list(params).then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy).toHaveBeenCalled(); | ||
ajaxRequest = ajaxSpy.calls.mostRecent().args[0]; | ||
done(); | ||
}); | ||
} | ||
}); | ||
@@ -36,0 +38,0 @@ |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
@@ -156,3 +156,3 @@ if (typeof process === 'object' && process + '' === '[object process]') { | ||
var ajaxRequest; | ||
var ajaxSpy = spyOn(axios, 'get').and.returnValue(Bluebird.resolve()); | ||
var ajaxSpy = spyOn(axios, 'get').and.returnValue(Promise.resolve()); | ||
var win = mockWindow(); | ||
@@ -222,3 +222,3 @@ var options = {win: win, clientId: 9999, refreshAccessTokenUrl: '/refresh'}; | ||
var accessToken = 'accessToken'; | ||
var ajaxSpy = spyOn(axios, 'post').and.returnValue(Bluebird.resolve({ | ||
var ajaxSpy = spyOn(axios, 'post').and.returnValue(Promise.resolve({ | ||
data: { | ||
@@ -278,3 +278,3 @@ 'access_token': accessToken | ||
var ajaxSpy = spyOn(axios, 'post').and.returnValue(Bluebird.resolve({ | ||
var ajaxSpy = spyOn(axios, 'post').and.returnValue(Promise.resolve({ | ||
data: { | ||
@@ -281,0 +281,0 @@ 'access_token': accessToken, |
'use strict'; | ||
var Bluebird = require('bluebird'); | ||
var assign = require('object-assign'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var pagination = require('../../../lib/pagination'); | ||
@@ -15,3 +15,3 @@ var Request = require('../../../lib/request'); | ||
var requestCreateSpy; | ||
var responsePromise = Bluebird.resolve({ | ||
var responsePromise = Promise.resolve({ | ||
headers: { | ||
@@ -18,0 +18,0 @@ Header: '123' |
'use strict'; | ||
var axios = require('axios'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
Bluebird.onPossiblyUnhandledRejection(function() {}); | ||
process.on('unhandledRejection', function() {}); | ||
@@ -39,9 +39,12 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; | ||
var fun = getMockPromises( | ||
Bluebird.resolve({ status: 200, headers: {} }) | ||
Promise.resolve({ status: 200, headers: {} }) | ||
); | ||
spyOn(axios, 'request').and.callFake(fun); | ||
myRequest.send().finally(function() { | ||
myRequest.send().then(_finally, _finally); | ||
function _finally() { | ||
expect(myRequest.request.headers.hasOwnProperty('foo')).toBe(false); | ||
}).finally(done); | ||
done(); | ||
} | ||
}); | ||
@@ -54,10 +57,12 @@ | ||
var fun = getMockPromises( | ||
Bluebird.resolve({ status: 200, headers: {} }) | ||
Promise.resolve({ status: 200, headers: {} }) | ||
); | ||
spyOn(axios, 'request').and.callFake(fun); | ||
myRequest.send().finally(function() { | ||
myRequest.send().then(_finally, _finally); | ||
function _finally() { | ||
expect(myRequest.request.headers.Authorization).toEqual('Bearer auth'); | ||
}).finally(done); | ||
done(); | ||
} | ||
}); | ||
@@ -72,4 +77,4 @@ }); | ||
var fun = getMockPromises( | ||
Bluebird.reject({ response: { status: 401 } }), // Auth failure | ||
Bluebird.resolve({ status: 200, headers: {} }) // Original request success | ||
Promise.reject({ response: { status: 401 } }), // Auth failure | ||
Promise.resolve({ status: 200, headers: {} }) // Original request success | ||
); | ||
@@ -91,7 +96,7 @@ var ajaxSpy = spyOn(axios, 'request').and.callFake(fun); | ||
var fun = getMockPromises( | ||
Bluebird.reject({ response: { status: 401 } }), // Auth failure | ||
Bluebird.resolve({ status: 200, headers: {} }) // Original request success | ||
Promise.reject({ response: { status: 401 } }), // Auth failure | ||
Promise.resolve({ status: 200, headers: {} }) // Original request success | ||
); | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(fun); | ||
var authRefreshSpy = spyOn(mockAuthInterface, 'refreshToken').and.returnValue(Bluebird.reject({ status: 500 })); | ||
var authRefreshSpy = spyOn(mockAuthInterface, 'refreshToken').and.returnValue(Promise.reject({ status: 500 })); | ||
var authAuthenticateSpy = spyOn(mockAuthInterface, 'authenticate').and.callThrough(); | ||
@@ -111,3 +116,3 @@ | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.reject(mockAuth.unauthorisedError)); | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.reject(mockAuth.unauthorisedError)); | ||
var authRefreshSpy = spyOn(mockAuthInterface, 'refreshToken').and.callThrough(); | ||
@@ -120,3 +125,3 @@ var authAuthenticateSpy = spyOn(mockAuthInterface, 'authenticate').and.callThrough(); | ||
expect(authAuthenticateSpy.calls.count()).toEqual(1); | ||
}).finally(done); | ||
}).then(done, done); | ||
}); | ||
@@ -126,7 +131,7 @@ | ||
var mockAuthInterface = mockAuth.slowAuthCodeFlow(); | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValue(Bluebird.reject(mockAuth.unauthorisedError)); | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValue(Promise.reject(mockAuth.unauthorisedError)); | ||
var authRefreshSpy = spyOn(mockAuthInterface, 'refreshToken').and.callThrough(); | ||
var authAuthenticateSpy = spyOn(mockAuthInterface, 'authenticate').and.callThrough(); | ||
Bluebird.all([ | ||
Promise.all([ | ||
request.create({ method: 'get' }, { authFlow: mockAuthInterface }).send(), | ||
@@ -146,6 +151,6 @@ request.create({ method: 'get' }, { authFlow: mockAuthInterface }).send() | ||
if (config.headers.Authorization === 'Bearer auth-refreshed-1') { | ||
return Bluebird.resolve({ status: 200, headers: {} }); | ||
return Promise.resolve({ status: 200, headers: {} }); | ||
} | ||
return Bluebird.reject({ | ||
return Promise.reject({ | ||
response: mockAuth.unauthorisedError | ||
@@ -156,3 +161,3 @@ }); | ||
Bluebird.all([ | ||
Promise.all([ | ||
request.create({ method: 'get' }, { authFlow: mockAuthInterface }).send(), | ||
@@ -177,4 +182,4 @@ request.create({ method: 'get' }, { authFlow: mockAuthInterface }).send(), | ||
var myRequest = request.create({ method: 'get' }, { authFlow: mockAuthInterface }); | ||
spyOn(axios, 'request').and.returnValue(Bluebird.reject({ response: { status: 401 } })); | ||
spyOn(mockAuthInterface, 'refreshToken').and.returnValue(Bluebird.reject(refreshError)); | ||
spyOn(axios, 'request').and.returnValue(Promise.reject({ response: { status: 401 } })); | ||
spyOn(mockAuthInterface, 'refreshToken').and.returnValue(Promise.reject(refreshError)); | ||
@@ -192,11 +197,13 @@ myRequest.send().catch(function(caughtError) { | ||
var fun = getMockPromises( | ||
Bluebird.reject(mockAuth.unauthorisedError), | ||
Bluebird.resolve({ status: 200, headers: {} }) | ||
Promise.reject(mockAuth.unauthorisedError), | ||
Promise.resolve({ status: 200, headers: {} }) | ||
); | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(fun); | ||
myRequest.send().finally(function() { | ||
myRequest.send().then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy.calls.count()).toEqual(1); | ||
}).finally(done); | ||
done(); | ||
} | ||
}); | ||
@@ -207,10 +214,13 @@ | ||
var fun = getMockPromises( | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.resolve({ status: 200, headers: {} }) | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.resolve({ status: 200, headers: {} }) | ||
); | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(fun); | ||
myRequest.send().finally(function() { | ||
myRequest.send().then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy.calls.count()).toEqual(2); | ||
}).finally(done); | ||
done(); | ||
} | ||
}); | ||
@@ -222,5 +232,5 @@ | ||
var fun = getMockPromises( | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.resolve({ status: 200, headers: {} }) | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.resolve({ status: 200, headers: {} }) | ||
); | ||
@@ -238,19 +248,21 @@ var ajaxSpy = spyOn(axios, 'request').and.callFake(fun); | ||
var fun = getMockPromises( | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.reject(mockAuth.timeoutError), | ||
Bluebird.resolve({ status: 200, headers: {} }) | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.reject(mockAuth.timeoutError), | ||
Promise.resolve({ status: 200, headers: {} }) | ||
); | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(fun); | ||
myRequest.send().finally(function() { | ||
myRequest.send().then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy.calls.count()).toEqual(10); | ||
done(); | ||
}).catch(function() {}); | ||
} | ||
}); | ||
@@ -261,9 +273,9 @@ | ||
var ajaxSpy = spyOn(axios, 'request').and.returnValues( | ||
Bluebird.reject({ response: { status: 401 } }), // request auth fail | ||
Bluebird.reject({ response: { status: 401 } }), // request auth fail | ||
Bluebird.resolve({ status: 200, headers: {} }) // request success | ||
Promise.reject({ response: { status: 401 } }), // request auth fail | ||
Promise.reject({ response: { status: 401 } }), // request auth fail | ||
Promise.resolve({ status: 200, headers: {} }) // request success | ||
); | ||
var refreshTokenSpy = spyOn(mockAuthInterface, 'refreshToken').and.returnValues( | ||
Bluebird.reject({ response: { status: 401 } }), // token request fail | ||
Bluebird.resolve({ status: 200, headers: {} }) // token request success | ||
Promise.reject({ response: { status: 401 } }), // token request fail | ||
Promise.resolve({ status: 200, headers: {} }) // token request success | ||
); | ||
@@ -292,4 +304,4 @@ | ||
var fun = getMockPromises( | ||
Bluebird.reject(mockAuth.notFoundError), | ||
Bluebird.resolve({ status: 200, headers: {} }) | ||
Promise.reject(mockAuth.notFoundError), | ||
Promise.resolve({ status: 200, headers: {} }) | ||
); | ||
@@ -300,3 +312,3 @@ var ajaxSpy = spyOn(axios, 'request').and.callFake(fun); | ||
expect(ajaxSpy.calls.count()).toEqual(1); | ||
}).finally(done); | ||
}).then(done, done); | ||
}); | ||
@@ -307,10 +319,13 @@ | ||
var fun = getMockPromises( | ||
Bluebird.reject(mockAuth.unavailableError), | ||
Bluebird.resolve({ status: 200, headers: {} }) | ||
Promise.reject(mockAuth.unavailableError), | ||
Promise.resolve({ status: 200, headers: {} }) | ||
); | ||
var ajaxSpy = spyOn(axios, 'request').and.callFake(fun); | ||
myRequest.send().finally(function() { | ||
myRequest.send().then(_finally, _finally); | ||
function _finally() { | ||
expect(ajaxSpy.calls.count()).toEqual(2); | ||
}).finally(done); | ||
done(); | ||
} | ||
}); | ||
@@ -322,4 +337,4 @@ | ||
var fun = getMockPromises( | ||
Bluebird.reject(error), | ||
Bluebird.resolve({ status: 200, headers: {} }) | ||
Promise.reject(error), | ||
Promise.resolve({ status: 200, headers: {} }) | ||
); | ||
@@ -330,5 +345,5 @@ spyOn(axios, 'request').and.callFake(fun); | ||
expect(e).toEqual(error); | ||
}).finally(done); | ||
}).then(done, done); | ||
}); | ||
}); | ||
}); |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var assign = require('object-assign'); | ||
var Bluebird = require('bluebird'); | ||
var Promise = require('../../../lib/promise-proxy'); | ||
var authFlow = mockAuth.mockImplicitGrantFlow(); | ||
@@ -22,3 +22,3 @@ var requestCreateSpy; | ||
var responsePromise = Bluebird.resolve({ | ||
var responsePromise = Promise.resolve({ | ||
headers: { | ||
@@ -25,0 +25,0 @@ Header: '123' |
@@ -23,3 +23,3 @@ # UPGRADING | ||
// becomes | ||
spyOn(api.documents, 'create').and.returnValue(Bluebird.resolve()); | ||
spyOn(api.documents, 'create').and.returnValue(Promise.resolve()); | ||
``` | ||
@@ -37,3 +37,3 @@ | ||
plugins: [new webpack.ProvidePlugin({ | ||
Promise: 'bluebird' | ||
Promise: 'es6-promise-promise' | ||
})]; | ||
@@ -182,1 +182,13 @@ } | ||
1. Removes legacy `JSON.stringify` of request data as Axios handles this natively. This should be backwards compatible, but making a major release as could break user's unit tests if they attempt to extend the built-in Request object. | ||
## Upgrading to v8.x | ||
1. Removes the implicit Bluebird dependency. Bluebird, or any Promises/A+ implementation, can be provided to this SDK and all methods that previously returned a Bluebird promise will now return an instance of the implemention explicitly provided. For example: | ||
```javascript | ||
// old | ||
var api = require('@mendeley/api'); | ||
// new | ||
var api = require('@mendeley/api').withPromise(require('bluebird')); | ||
``` |
var webpack = require('webpack'); | ||
var plugins = [new webpack.ProvidePlugin({ | ||
Promise: 'bluebird' | ||
})]; | ||
var plugins = []; | ||
var useMinifier = (process.argv.slice(1).indexOf('--minify') !== -1); | ||
@@ -6,0 +4,0 @@ |
1536143
3
82
15847
390
24
- Removedbluebird@^3.4.0
- Removedbluebird@3.7.2(transitive)