|
552 | 552 | var callback = sinon.spy(); |
553 | 553 | var api = new SpotifyWebApi(); |
554 | 554 | api.setAccessToken('<example_access_token>'); |
555 | | - api.removeTracksFromPlaylistWithSnapshotId('jmperezperez', '7Kud0O2IdWLbEGgvBkW9di', [{uri: 'spotify:track:2Oehrcv4Kov0SuIgWyQY9e', position: 6}], 'AsNaPsHoTiD', callback); |
| 555 | + api.removeTracksFromPlaylistWithSnapshotId('jmperezperez', '7Kud0O2IdWLbEGgvBkW9di', [{uri: 'spotify:track:2Oehrcv4Kov0SuIgWyQY9e', positions: [6]}], 'AsNaPsHoTiD', callback); |
556 | 556 | that.requests[0].respond(200, |
557 | 557 | {'Content-Type':'application/json'}, |
558 | 558 | '' |
|
565 | 565 | expect(that.requests[0].requestBody).to.equal(JSON.stringify({ |
566 | 566 | tracks: [{ |
567 | 567 | uri: 'spotify:track:2Oehrcv4Kov0SuIgWyQY9e', |
568 | | - position: 6 |
| 568 | + positions: [6] |
569 | 569 | }], |
570 | 570 | snapshot_id: 'AsNaPsHoTiD' |
571 | 571 | })); |
572 | 572 | }); |
573 | 573 |
|
| 574 | + it('should remove tracks from a playlist specifying just their positions and snapshot id', function() { |
| 575 | + var callback = sinon.spy(); |
| 576 | + var api = new SpotifyWebApi(); |
| 577 | + api.setAccessToken('<example_access_token>'); |
| 578 | + api.removeTracksFromPlaylistInPositions('jmperezperez', '7Kud0O2IdWLbEGgvBkW9di', [0,1,3,9], 'AsNaPsHoTiD', callback); |
| 579 | + that.requests[0].respond(200, |
| 580 | + {'Content-Type':'application/json'}, |
| 581 | + '' |
| 582 | + ); |
| 583 | + expect(callback.calledWith(null, '')).to.be.ok; |
| 584 | + expect(that.requests).to.have.length(1); |
| 585 | + expect(that.requests[0].url).to.equal('https://api.spotify.com/v1/users/jmperezperez/playlists/7Kud0O2IdWLbEGgvBkW9di/tracks'); |
| 586 | + expect(that.requests[0].method).to.equal('DELETE'); |
| 587 | + expect(that.requests[0].status).to.equal(200); |
| 588 | + expect(that.requests[0].requestBody).to.equal(JSON.stringify({ |
| 589 | + positions: [0,1,3,9], |
| 590 | + snapshot_id: 'AsNaPsHoTiD' |
| 591 | + })); |
| 592 | + }); |
| 593 | + |
574 | 594 | it('should replace the tracks in a playlist', function() { |
575 | 595 | var callback = sinon.spy(); |
576 | 596 | var api = new SpotifyWebApi(); |
|
0 commit comments