Skip to content

Commit

Permalink
feat(libraryapi.ts): add singular variants of 'removeSaved*'
Browse files Browse the repository at this point in the history
Adds 'removeSavedAlbum', 'removeSavedShow', and 'removeSavedTrack'.
  • Loading branch information
adamgrieger committed Jun 14, 2020
1 parent 2dce48e commit d7f51d5
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/apis/LibraryApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,20 @@ describe('LibraryApi', () => {
});
});

describe('removeSavedAlbum', () => {
it('should remove an album for the current user', async () => {
const { httpMock, library } = setup();

await library.removeSavedAlbum('foo');

expect(httpMock.delete).toBeCalledWith('/me/albums', {
data: {
ids: ['foo'],
},
});
});
});

describe('removeSavedAlbums', () => {
it('should remove albums for the current user', async () => {
const { httpMock, library } = setup();
Expand All @@ -234,6 +248,33 @@ describe('LibraryApi', () => {
});
});

describe('removeSavedShow', () => {
it('should remove a show for the current user (without options)', async () => {
const { httpMock, library } = setup();

await library.removeSavedShow('foo');

expect(httpMock.delete).toBeCalledWith('/me/shows', {
params: {
ids: ['foo'],
},
});
});

it('should remove a show for the current user (with options)', async () => {
const { httpMock, library } = setup();

await library.removeSavedShow('foo', { market: 'bar' });

expect(httpMock.delete).toBeCalledWith('/me/shows', {
params: {
ids: ['foo'],
market: 'bar',
},
});
});
});

describe('removeSavedShows', () => {
it('should remove shows for the current user (without options)', async () => {
const { httpMock, library } = setup();
Expand Down Expand Up @@ -261,6 +302,20 @@ describe('LibraryApi', () => {
});
});

describe('removeSavedTrack', () => {
it('should remove a track for the current user', async () => {
const { httpMock, library } = setup();

await library.removeSavedTrack('foo');

expect(httpMock.delete).toBeCalledWith('/me/tracks', {
data: {
ids: ['foo'],
},
});
});
});

describe('removeSavedTracks', () => {
it('should remove tracks for the current user', async () => {
const { httpMock, library } = setup();
Expand Down
37 changes: 37 additions & 0 deletions src/apis/LibraryApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ export class LibraryApi {
return response[0];
}

/**
* Remove Album for the Current User
*
* Remove an album from the current user's library.
*
* @param albumId The Spotify ID of the album.
*/
removeSavedAlbum(albumId: string): Promise<void> {
return this.removeSavedAlbums([albumId]);
}

/**
* Remove Albums for the Current User
*
Expand All @@ -162,6 +173,21 @@ export class LibraryApi {
});
}

/**
* Remove Show for the Current User
*
* Remove a show from the current user's library.
*
* @param showId The Spotify ID of the show.
* @param options Optional request information.
*/
removeSavedShow(
showId: string,
options?: RemoveSavedShowsOptions,
): Promise<void> {
return this.removeSavedShows([showId], options);
}

/**
* Remove Shows for the Current User
*
Expand All @@ -182,6 +208,17 @@ export class LibraryApi {
});
}

/**
* Remove Track for the Current User
*
* Remove a track from the current user's library.
*
* @param trackId The Spotify ID of the track.
*/
removeSavedTrack(trackId: string): Promise<void> {
return this.removeSavedTracks([trackId]);
}

/**
* Remove Tracks for the Current User
*
Expand Down

0 comments on commit d7f51d5

Please sign in to comment.