@@ -1512,14 +1512,36 @@ describe('Spotify Web API', () => {
1512
1512
} ) ;
1513
1513
} ) ;
1514
1514
1515
- test . skip ( 'should create a playlist' , function ( done ) {
1515
+ test ( 'should create a playlist' , function ( done ) {
1516
+ sinon . stub ( HttpManager , '_makeRequest' , function (
1517
+ method ,
1518
+ options ,
1519
+ uri ,
1520
+ callback
1521
+ ) {
1522
+ expect ( method ) . toBe ( superagent . post ) ;
1523
+ expect ( uri ) . toBe (
1524
+ 'https://api.spotify.com/v1/me/playlists'
1525
+ ) ;
1526
+ expect ( JSON . parse ( options . data ) ) . toEqual ( {
1527
+ name : 'My Cool Playlist'
1528
+ } ) ;
1529
+ expect ( options . query ) . toBeFalsy ( ) ;
1530
+ callback ( null , {
1531
+ body : { name : 'My Cool Playlist' } ,
1532
+ statusCode : 200
1533
+ } ) ;
1534
+ } ) ;
1535
+
1516
1536
var api = new SpotifyWebApi ( ) ;
1517
1537
api . setAccessToken ( 'long-access-token' ) ;
1518
1538
1519
1539
api
1520
- . createPlaylist ( 'thelinmichael' , ' My Cool Playlist', { public : true } )
1540
+ . createPlaylist ( 'My Cool Playlist' )
1521
1541
. then (
1522
1542
function ( data ) {
1543
+ expect ( data . body . name ) . toBe ( 'My Cool Playlist' ) ;
1544
+ expect ( data . statusCode ) . toBe ( 200 ) ;
1523
1545
done ( ) ;
1524
1546
} ,
1525
1547
function ( err ) {
@@ -1538,55 +1560,58 @@ describe('Spotify Web API', () => {
1538
1560
) {
1539
1561
expect ( method ) . toBe ( superagent . post ) ;
1540
1562
expect ( uri ) . toBe (
1541
- 'https://api.spotify.com/v1/users/thelinmichael /playlists'
1563
+ 'https://api.spotify.com/v1/me /playlists'
1542
1564
) ;
1543
1565
expect ( JSON . parse ( options . data ) ) . toEqual ( {
1544
1566
name : 'My Cool Playlist' ,
1567
+ description : 'It\'s really cool' ,
1545
1568
public : false
1546
1569
} ) ;
1547
1570
expect ( options . query ) . toBeFalsy ( ) ;
1548
1571
callback ( null , {
1549
- body : { name : 'My Cool Playlist' , public : false } ,
1572
+ body : { name : 'My Cool Playlist' , description : 'It\s really cool' , public : false } ,
1550
1573
statusCode : 200
1551
1574
} ) ;
1552
1575
} ) ;
1553
1576
1554
1577
var api = new SpotifyWebApi ( ) ;
1555
1578
1556
1579
api . createPlaylist (
1557
- 'thelinmichael' ,
1558
1580
'My Cool Playlist' ,
1581
+ { description : 'It\'s really cool' } ,
1559
1582
{ public : false } ,
1560
1583
function ( err , data ) {
1561
1584
expect ( data . body . name ) . toBe ( 'My Cool Playlist' ) ;
1585
+ expect ( data . body . description ) . toBe ( 'It\s really cool' ) ;
1586
+ expect ( data . body . public ) . toBe ( false ) ;
1562
1587
expect ( data . statusCode ) . toBe ( 200 ) ;
1563
1588
done ( ) ;
1564
1589
}
1565
1590
) ;
1566
1591
} ) ;
1567
1592
1568
- test ( 'should create a playlist using callback without options ' , done => {
1569
- sinon . stub ( HttpManager , '_makeRequest' ) . callsFake ( function (
1593
+ test ( 'should create a playlist using callback with user id ' , done => {
1594
+ sinon . stub ( HttpManager , '_makeRequest' , function (
1570
1595
method ,
1571
1596
options ,
1572
1597
uri ,
1573
1598
callback
1574
1599
) {
1575
1600
expect ( method ) . toBe ( superagent . post ) ;
1576
1601
expect ( uri ) . toBe (
1577
- 'https://api.spotify.com/v1/users/thelinmichael /playlists'
1602
+ 'https://api.spotify.com/v1/me /playlists'
1578
1603
) ;
1579
1604
expect ( JSON . parse ( options . data ) ) . toEqual ( { name : 'My Cool Playlist' } ) ;
1580
- callback ( null , { body : { name : 'My Cool Playlist' } } ) ;
1605
+ callback ( null , { body : { name : 'My Cool Playlist' } , statusCode : 200 } ) ;
1581
1606
expect ( options . query ) . toBeFalsy ( ) ;
1582
1607
} ) ;
1583
1608
1584
1609
var api = new SpotifyWebApi ( ) ;
1585
1610
1586
- api . createPlaylist ( 'thelinmichael' , 'My Cool Playlist' , function (
1587
- err ,
1588
- data
1589
- ) {
1611
+ api . createPlaylist ( 'thelinmichael' , 'My Cool Playlist' , { } ,
1612
+ function ( err , data ) {
1613
+ expect ( data . body . name ) . toBe ( 'My Cool Playlist' ) ;
1614
+ expect ( data . statusCode ) . toBe ( 200 ) ;
1590
1615
done ( ) ;
1591
1616
} ) ;
1592
1617
} ) ;
0 commit comments