Skip to content

Commit

Permalink
feat(playlistsapi.ts): add 'removePlaylistItem'
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgrieger committed Jun 15, 2020
1 parent 4138bd1 commit 7c5a9de
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/apis/PlaylistsApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,25 @@ describe('PlaylistsApi', () => {
});
});

describe('removePlaylistItem', () => {
beforeEach(() => {
HttpMock.prototype.delete.mockResolvedValue(snapshotIdFixture);
});

it('should remove an item from a playlist', async () => {
const { httpMock, playlists } = setup();

const response = await playlists.removePlaylistItem('foo', 'bar');

expect(response).toBe(snapshotIdFixture.snapshot_id);
expect(httpMock.delete).toBeCalledWith('/playlists/foo/tracks', {
data: {
tracks: [{ uri: 'bar' }],
},
});
});
});

describe('removePlaylistItems', () => {
beforeEach(() => {
HttpMock.prototype.delete.mockResolvedValue(snapshotIdFixture);
Expand Down
12 changes: 12 additions & 0 deletions src/apis/PlaylistsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ export class PlaylistsApi {
);
}

/**
* Remove Item from a Playlist
*
* Remove an item from a user's playlist.
*
* @param playlistId The Spotify ID for the playlist.
* @param uri The Spotify track or episode URI to remove.
*/
removePlaylistItem(playlistId: string, uri: string): Promise<string> {
return this.removePlaylistItems(playlistId, [uri]);
}

/**
* Remove Items from a Playlist
*
Expand Down

0 comments on commit 7c5a9de

Please sign in to comment.