File tree 2 files changed +40
-1
lines changed
2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -1447,6 +1447,41 @@ describe('Spotify Web API', () => {
1447
1447
} ) ;
1448
1448
} ) ;
1449
1449
1450
+ test ( 'should get the current users playlists with options' , done => {
1451
+ sinon . stub ( HttpManager , '_makeRequest' , function (
1452
+ method ,
1453
+ options ,
1454
+ uri ,
1455
+ callback
1456
+ ) {
1457
+ expect ( method ) . toBe ( superagent . get ) ;
1458
+ expect ( uri ) . toBe ( 'https://api.spotify.com/v1/me/playlists' ) ;
1459
+ expect ( options . query ) . toEqual ( { limit : 27 , offset : 7 } ) ;
1460
+ callback ( null , {
1461
+ body : {
1462
+ items : [
1463
+ {
1464
+ uri : 'spotify:user:thelinmichael:playlist:5ieJqeLJjjI8iJWaxeBLuK'
1465
+ } ,
1466
+ {
1467
+ uri : 'spotify:user:thelinmichael:playlist:3EsfV6XzCHU8SPNdbnFogK'
1468
+ }
1469
+ ]
1470
+ } ,
1471
+ statusCode : 200
1472
+ } ) ;
1473
+ } ) ;
1474
+
1475
+ var api = new SpotifyWebApi ( ) ;
1476
+ api . setAccessToken ( 'myVeryLongAccessToken' ) ;
1477
+
1478
+ api . getUserPlaylists ( { limit : 27 , offset : 7 } ) . then ( function ( data ) {
1479
+ expect ( 2 ) . toBe ( data . body . items . length ) ;
1480
+ expect ( data . statusCode ) . toBe ( 200 ) ;
1481
+ done ( ) ;
1482
+ } ) ;
1483
+ } ) ;
1484
+
1450
1485
test ( 'should get a playlist' , done => {
1451
1486
sinon . stub ( HttpManager , '_makeRequest' , function (
1452
1487
method ,
Original file line number Diff line number Diff line change @@ -457,7 +457,11 @@ SpotifyWebApi.prototype = {
457
457
var path ;
458
458
if ( typeof userId === 'string' ) {
459
459
path = '/v1/users/' + encodeURIComponent ( userId ) + '/playlists' ;
460
- } else {
460
+ } else if ( typeof userId === 'object' ) {
461
+ callback = options ;
462
+ options = userId ;
463
+ path = '/v1/me/playlists' ;
464
+ } /* undefined */ else {
461
465
path = '/v1/me/playlists' ;
462
466
}
463
467
You can’t perform that action at this time.
0 commit comments